aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Scalar/LoopFlatten.cpp
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@sifive.com>2022-06-07 08:21:20 -0700
committerCraig Topper <craig.topper@sifive.com>2022-06-07 08:21:21 -0700
commitd73684e22334f1411abb02e4fb16c18f723a96a2 (patch)
treed773db1179fbbf91c0b57a65b04aff5e39f6efad /llvm/lib/Transforms/Scalar/LoopFlatten.cpp
parentfdd5843572c02bea2ac4d537a09b32e633994a8a (diff)
downloadllvm-d73684e22334f1411abb02e4fb16c18f723a96a2.zip
llvm-d73684e22334f1411abb02e4fb16c18f723a96a2.tar.gz
llvm-d73684e22334f1411abb02e4fb16c18f723a96a2.tar.bz2
[LoopFlatten] Fix crash if the inner loop trip count comes from a sext instruction.
If we look through a truncate in matchLinearIVUser, it's possible we find a sext/zext instruction that didn't come from widening. This will fail the MatchedItCount->getType() == InnerInductionPHI->getType() assertion. Fix this by checking that we did not look through a truncate already. Reviewed By: SjoerdMeijer Differential Revision: https://reviews.llvm.org/D127149
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LoopFlatten.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/LoopFlatten.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopFlatten.cpp b/llvm/lib/Transforms/Scalar/LoopFlatten.cpp
index de05d69..eb12def 100644
--- a/llvm/lib/Transforms/Scalar/LoopFlatten.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopFlatten.cpp
@@ -211,8 +211,9 @@ struct FlattenInfo {
if (!MatchedItCount)
return false;
- // Look through extends if the IV has been widened.
- if (Widened &&
+ // Look through extends if the IV has been widened. Don't look through
+ // extends if we already looked through a trunc.
+ if (Widened && IsAdd &&
(isa<SExtInst>(MatchedItCount) || isa<ZExtInst>(MatchedItCount))) {
assert(MatchedItCount->getType() == InnerInductionPHI->getType() &&
"Unexpected type mismatch in types after widening");