[llvm] [LV] Add assertion for loop predecessor (and terminator of) existing when checking out of loop inst for poison (PR #154603)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 20 13:12:00 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-vectorizers
Author: None (calebwat)
<details>
<summary>Changes</summary>
In LoopVectorizationLegality, TheLoop->getLoopPredecessor() and [...]Predecessor()->getTerminator() are used without a null check. This patch adds an assert that they are non-null, since they are expected to be defined.
---
Full diff: https://github.com/llvm/llvm-project/pull/154603.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp (+5)
``````````diff
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
index 789047a2a28e7..5882b2b5466d9 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
@@ -1527,6 +1527,11 @@ bool LoopVectorizationLegality::canVectorizeWithIfConvert() {
if (!CurrI || !TheLoop->contains(CurrI)) {
// If operands from outside the loop may be poison then Ptr may also
// be poison.
+ assert((TheLoop->getLoopPredecessor() &&
+ TheLoop->getLoopPredecessor()->getTerminator()) &&
+ "No loop predecessor/pred terminator found while checking "
+ "out of loop instruction for poison");
+
if (!isGuaranteedNotToBePoison(CurrV, AC,
TheLoop->getLoopPredecessor()
->getTerminator()
``````````
</details>
https://github.com/llvm/llvm-project/pull/154603
More information about the llvm-commits
mailing list