[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 10:10:45 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.
----------------
arsenm wrote:

So the expression is unknown - unknown = 0? That is surprising behavior. I would expect to filter out either half being unknown 

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


More information about the llvm-commits mailing list