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

Paul Osmialowski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 4 11:09:31 PDT 2023


pawosm01 updated this revision to Diff 510862.
pawosm01 added a comment.

I'm trying to build a relation between D146974 <https://reviews.llvm.org/D146974> and D146958 <https://reviews.llvm.org/D146958>.


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/lib/Analysis/VectorUtils.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
@@ -1,4 +1,3 @@
-; FIXME: this will fail unless D146958 is applied.
 ; RUN: opt -passes=loop-vectorize -force-vector-width=2 -force-vector-interleave=1 -S < %s | FileCheck %s
 
 define void @foo(ptr %pout, ptr %pin, i64 %val0, i64 %val1, i64 %val2) {
Index: llvm/lib/Analysis/VectorUtils.cpp
===================================================================
--- llvm/lib/Analysis/VectorUtils.cpp
+++ llvm/lib/Analysis/VectorUtils.cpp
@@ -1157,6 +1157,12 @@
       Value *Ptr = getLoadStorePointerOperand(&I);
       if (!Ptr)
         continue;
+
+      // If the pointer is invariant then there is no stride and it makes no
+      // sense to add it here.
+      if (TheLoop->isLoopInvariant(Ptr))
+        continue;
+
       Type *ElementTy = getLoadStoreType(&I);
 
       // Currently, codegen doesn't support cases where the type size doesn't
Index: llvm/lib/Analysis/LoopAccessAnalysis.cpp
===================================================================
--- llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -2561,6 +2561,11 @@
   if (!Ptr)
     return;
 
+  // If the pointer is invariant then there is no stride and it makes no
+  // sense to add it here.
+  if (TheLoop->isLoopInvariant(Ptr))
+    return;
+
   Value *Stride = getStrideFromPointer(Ptr, PSE->getSE(), TheLoop);
   if (!Stride)
     return;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146958.510862.patch
Type: text/x-patch
Size: 1617 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230404/14147b42/attachment.bin>


More information about the llvm-commits mailing list