[llvm] [LV] Fix unsafe canVectorizeWithIfConvert() checks (PR #203273)
Sander de Smalen via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 12 06:42:01 PDT 2026
================
@@ -2962,7 +2962,10 @@ bool LoopAccessInfo::blockNeedsPredication(const BasicBlock *BB,
assert(TheLoop->contains(BB) && "Unknown block used");
// Blocks that do not dominate the latch need predication.
+ // Treat blocks in loops with no unique latch as always needing predication.
const BasicBlock *Latch = TheLoop->getLoopLatch();
+ if (!Latch)
----------------
sdesmalen-arm wrote:
Is this basically returning an arbitrary value? (e.g. when I change it to `false`, nothing fails)
If not, then why should it return `true` rather than `false`?
My initial thought is that it should never ask this question when the loop cannot be handled by the LV. If it were to return `false` at the start of `LoopVectorizationLegality::canVectorizeWithIfConvert` then it never queries `blockNeedsPredication`, because its answer would be meaningless.
https://github.com/llvm/llvm-project/pull/203273
More information about the llvm-commits
mailing list