aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
diff options
context:
space:
mode:
authorRoman Lebedev <lebedev.ri@gmail.com>2020-10-12 22:19:17 +0300
committerRoman Lebedev <lebedev.ri@gmail.com>2020-10-12 23:02:55 +0300
commit1fb610429308a7c29c5065f5cc35dcc3fd69c8b1 (patch)
treebd42e12403afa96609eaae626e5d4328bde87756 /llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
parent73818f450e3a90fc89eca143ee30777ed7e660e9 (diff)
downloadllvm-1fb610429308a7c29c5065f5cc35dcc3fd69c8b1.zip
llvm-1fb610429308a7c29c5065f5cc35dcc3fd69c8b1.tar.gz
llvm-1fb610429308a7c29c5065f5cc35dcc3fd69c8b1.tar.bz2
Reland "[SCEV] Model ptrtoint(SCEVUnknown) cast not as unknown, but as zext/trunc/self of SCEVUnknown"
This relands commit 1c021c64caef83cccb719c9bf0a2554faa6563af which was reverted in commit 17cec6a11a12f815052d56a17ef738cf246a2d9a because an assertion was being triggered, since `BuildConstantFromSCEV()` wasn't updated to handle the case where the constant we want to truncate is actually a pointer. I was unsuccessful in coming up with a test case where we'd end there with constant zext/sext of a pointer, so i didn't handle those cases there until there is a test case. Original commit message: While we indeed can't treat them as no-ops, i believe we can/should do better than just modelling them as `unknown`. `inttoptr` story is complicated, but for `ptrtoint`, it seems straight-forward to model it just as a zext-or-trunc of unknown. This may be important now that we track towards making inttoptr/ptrtoint casts not no-op, and towards preventing folding them into loads/etc (see D88979/D88789/D88788) Reviewed By: mkazantsev Differential Revision: https://reviews.llvm.org/D88806
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyIndVar.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyIndVar.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
index 2d71b0f..3e280a6 100644
--- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
@@ -427,7 +427,7 @@ static bool willNotOverflow(ScalarEvolution *SE, Instruction::BinaryOps BinOp,
: &ScalarEvolution::getZeroExtendExpr;
// Check ext(LHS op RHS) == ext(LHS) op ext(RHS)
- auto *NarrowTy = cast<IntegerType>(LHS->getType());
+ auto *NarrowTy = cast<IntegerType>(SE->getEffectiveSCEVType(LHS->getType()));
auto *WideTy =
IntegerType::get(NarrowTy->getContext(), NarrowTy->getBitWidth() * 2);