[llvm] LSV: forbid load-cycles when vectorizing; fix bug (PR #104815)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 19 09:36:30 PDT 2024


================
@@ -1499,6 +1499,12 @@ std::optional<APInt> Vectorizer::getConstantOffset(Value *PtrA, Value *PtrB,
 
   // Try to compute B - A.
   const SCEV *DistScev = SE.getMinusSCEV(SE.getSCEV(PtrB), SE.getSCEV(PtrA));
+  if (DistScev->isZero()) {
+    // A load in the chain is dependent on another load in the chain, and
+    // attempting to vectorize this chain would create a cycle.
+    LLVM_DEBUG(dbgs() << "LSV: SCEV diff is zero; not vectorizing\n");
+    return std::nullopt;
+  }
----------------
arsenm wrote:

blank line after 

https://github.com/llvm/llvm-project/pull/104815


More information about the llvm-commits mailing list