Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Scalar] Use LLVMContext::MD_mem_parallel_loop_access directly (NFC) #69549

Merged

Conversation

kazutakahirata
Copy link
Contributor

This patch "constant propagates"
LLVMContext::MD_mem_parallel_loop_access into wherever
ParallelLoopAccessMDKind is used.

This patch "constant propagates"
LLVMContext::MD_mem_parallel_loop_access into wherever
ParallelLoopAccessMDKind is used.
@llvmbot
Copy link
Member

llvmbot commented Oct 19, 2023

@llvm/pr-subscribers-llvm-transforms

Author: Kazu Hirata (kazutakahirata)

Changes

This patch "constant propagates"
LLVMContext::MD_mem_parallel_loop_access into wherever
ParallelLoopAccessMDKind is used.


Full diff: https://github.com/llvm/llvm-project/pull/69549.diff

1 Files Affected:

  • (modified) llvm/lib/Transforms/Scalar/Scalarizer.cpp (+7-12)
diff --git a/llvm/lib/Transforms/Scalar/Scalarizer.cpp b/llvm/lib/Transforms/Scalar/Scalarizer.cpp
index 111c477337535f0..f5e480ae36bf42c 100644
--- a/llvm/lib/Transforms/Scalar/Scalarizer.cpp
+++ b/llvm/lib/Transforms/Scalar/Scalarizer.cpp
@@ -282,12 +282,10 @@ T getWithDefaultOverride(const cl::opt<T> &ClOption,
 
 class ScalarizerVisitor : public InstVisitor<ScalarizerVisitor, bool> {
 public:
-  ScalarizerVisitor(unsigned ParallelLoopAccessMDKind, DominatorTree *DT,
-                    ScalarizerPassOptions Options)
-      : ParallelLoopAccessMDKind(ParallelLoopAccessMDKind), DT(DT),
-        ScalarizeVariableInsertExtract(
-            getWithDefaultOverride(ClScalarizeVariableInsertExtract,
-                                   Options.ScalarizeVariableInsertExtract)),
+  ScalarizerVisitor(DominatorTree *DT, ScalarizerPassOptions Options)
+      : DT(DT), ScalarizeVariableInsertExtract(getWithDefaultOverride(
+                    ClScalarizeVariableInsertExtract,
+                    Options.ScalarizeVariableInsertExtract)),
         ScalarizeLoadStore(getWithDefaultOverride(ClScalarizeLoadStore,
                                                   Options.ScalarizeLoadStore)),
         ScalarizeMinBits(getWithDefaultOverride(ClScalarizeMinBits,
@@ -337,8 +335,6 @@ class ScalarizerVisitor : public InstVisitor<ScalarizerVisitor, bool> {
 
   SmallVector<WeakTrackingVH, 32> PotentiallyDeadInstrs;
 
-  unsigned ParallelLoopAccessMDKind;
-
   DominatorTree *DT;
 
   const bool ScalarizeVariableInsertExtract;
@@ -448,8 +444,7 @@ bool ScalarizerLegacyPass::runOnFunction(Function &F) {
     return false;
 
   DominatorTree *DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
-  ScalarizerVisitor Impl(LLVMContext::MD_mem_parallel_loop_access, DT,
-                         ScalarizerPassOptions());
+  ScalarizerVisitor Impl(DT, ScalarizerPassOptions());
   return Impl.visit(F);
 }
 
@@ -556,7 +551,7 @@ bool ScalarizerVisitor::canTransferMetadata(unsigned Tag) {
           || Tag == LLVMContext::MD_invariant_load
           || Tag == LLVMContext::MD_alias_scope
           || Tag == LLVMContext::MD_noalias
-          || Tag == ParallelLoopAccessMDKind
+          || Tag == LLVMContext::MD_mem_parallel_loop_access
           || Tag == LLVMContext::MD_access_group);
 }
 
@@ -1253,7 +1248,7 @@ bool ScalarizerVisitor::finish() {
 
 PreservedAnalyses ScalarizerPass::run(Function &F, FunctionAnalysisManager &AM) {
   DominatorTree *DT = &AM.getResult<DominatorTreeAnalysis>(F);
-  ScalarizerVisitor Impl(LLVMContext::MD_mem_parallel_loop_access, DT, Options);
+  ScalarizerVisitor Impl(DT, Options);
   bool Changed = Impl.visit(F);
   PreservedAnalyses PA;
   PA.preserve<DominatorTreeAnalysis>();

@github-actions
Copy link

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff ab301d833a207c717adff9612a4e58fe963e6ff0 f0372d03e5d9c9968c3272e6cb1438412ba8c72a -- llvm/lib/Transforms/Scalar/Scalarizer.cpp
View the diff from clang-format here.
diff --git a/llvm/lib/Transforms/Scalar/Scalarizer.cpp b/llvm/lib/Transforms/Scalar/Scalarizer.cpp
index f5e480ae3..b2461607a 100644
--- a/llvm/lib/Transforms/Scalar/Scalarizer.cpp
+++ b/llvm/lib/Transforms/Scalar/Scalarizer.cpp
@@ -545,14 +545,13 @@ void ScalarizerVisitor::replaceUses(Instruction *Op, Value *CV) {
 // Return true if it is safe to transfer the given metadata tag from
 // vector to scalar instructions.
 bool ScalarizerVisitor::canTransferMetadata(unsigned Tag) {
-  return (Tag == LLVMContext::MD_tbaa
-          || Tag == LLVMContext::MD_fpmath
-          || Tag == LLVMContext::MD_tbaa_struct
-          || Tag == LLVMContext::MD_invariant_load
-          || Tag == LLVMContext::MD_alias_scope
-          || Tag == LLVMContext::MD_noalias
-          || Tag == LLVMContext::MD_mem_parallel_loop_access
-          || Tag == LLVMContext::MD_access_group);
+  return (Tag == LLVMContext::MD_tbaa || Tag == LLVMContext::MD_fpmath ||
+          Tag == LLVMContext::MD_tbaa_struct ||
+          Tag == LLVMContext::MD_invariant_load ||
+          Tag == LLVMContext::MD_alias_scope ||
+          Tag == LLVMContext::MD_noalias ||
+          Tag == LLVMContext::MD_mem_parallel_loop_access ||
+          Tag == LLVMContext::MD_access_group);
 }
 
 // Transfer metadata from Op to the instructions in CV if it is known

Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Seems to date back to the time when getMDKindID("llvm.mem.parallel_loop_access") was used to fetch this.

@bjacob bjacob removed their request for review October 19, 2023 13:08
@kazutakahirata kazutakahirata merged commit 697082d into llvm:main Oct 20, 2023
2 of 3 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_ParallelLoopAccessMDKind branch October 20, 2023 01:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants