[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:11:26 PDT 2025
https://github.com/calebwat created https://github.com/llvm/llvm-project/pull/154603
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.
>From 7b292d25c4c80a694a9798b8b213352335849cef Mon Sep 17 00:00:00 2001
From: "Watts, Caleb" <caleb.watts at intel.com>
Date: Wed, 20 Aug 2025 13:04:51 -0700
Subject: [PATCH] [LV] Add assertion for loop predecessor (and terminator of)
existing when checking out of loop inst for poison
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.
---
llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp | 5 +++++
1 file changed, 5 insertions(+)
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()
More information about the llvm-commits
mailing list