[PATCH] D146958: [SCEV] Do not plant SCEV checks unnecessarily

Paul Osmialowski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 25 07:06:14 PDT 2023


pawosm01 updated this revision to Diff 516794.
pawosm01 edited the summary of this revision.
pawosm01 added a comment.

Changes applied according to the reviewer's suggestion. With summary update.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146958/new/

https://reviews.llvm.org/D146958

Files:
  llvm/lib/Analysis/LoopAccessAnalysis.cpp
  llvm/test/Transforms/LoopVectorize/vector-no-scevcheck.ll


Index: llvm/test/Transforms/LoopVectorize/vector-no-scevcheck.ll
===================================================================
--- llvm/test/Transforms/LoopVectorize/vector-no-scevcheck.ll
+++ llvm/test/Transforms/LoopVectorize/vector-no-scevcheck.ll
@@ -5,8 +5,7 @@
 
 define void @foo(ptr %pout, ptr %pin, i64 %val0, i64 %val1, i64 %val2) {
 ; CHECK-LABEL: @foo(
-; FIXME: CHECK below needs to be changed to CHECK-NOT to confirm the change.
-; CHECK: vector.scevcheck
+; CHECK-NOT: vector.scevcheck
 ; CHECK: vector.body
 entry:
   %0 = getelementptr double, ptr %pin, i64 %val0
@@ -45,8 +44,7 @@
 
 define void @bar(ptr %pout, ptr %pin, i64 %val0, i64 %val1, i64 %val2) {
 ; CHECK-LABEL: @bar(
-; FIXME: CHECK below needs to be changed to CHECK-NOT to confirm the change.
-; CHECK: vector.scevcheck
+; CHECK-NOT: vector.scevcheck
 ; CHECK: vector.body
 entry:
   %0 = getelementptr double, ptr %pin, i64 %val0
Index: llvm/lib/Analysis/LoopAccessAnalysis.cpp
===================================================================
--- llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -2642,6 +2642,11 @@
   if (!S)
     return nullptr;
 
+  // If the pointer is invariant then there is no stride and it makes no
+  // sense to add it here.
+  if (Lp != S->getLoop())
+    return nullptr;
+
   V = S->getStepRecurrence(*SE);
   if (!V)
     return nullptr;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146958.516794.patch
Type: text/x-patch
Size: 1400 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230425/0294c4e1/attachment.bin>


More information about the llvm-commits mailing list