[llvm] LSV: forbid load-cycles when vectorizing; fix bug (PR #104815)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 19 10:06:03 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.
----------------
artagnon wrote:
The SCEV expression corresponding to `%gep.x.2` is computed as the SCEVUnknown `%x`, which I think is correct. Did you expect an AddExpr?
It took me some time to figure out the fix, although it's quite a simple one in its final form: I think the patch correctly identifies the root cause.
https://github.com/llvm/llvm-project/pull/104815
More information about the llvm-commits
mailing list