aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
diff options
context:
space:
mode:
authorzhongyunde <zhongyunde@huawei.com>2023-06-03 22:28:55 +0800
committerzhongyunde <zhongyunde@huawei.com>2023-06-03 22:29:09 +0800
commit34d380e1f63a7e2cdb9ab1e6498f727fcd710a14 (patch)
treec181fd54fd66155654d8733c530374ee7cd30d16 /llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
parent287f201f9db866a10b4c4f9f6fe65c9d68525983 (diff)
downloadllvm-34d380e1f63a7e2cdb9ab1e6498f727fcd710a14.zip
llvm-34d380e1f63a7e2cdb9ab1e6498f727fcd710a14.tar.gz
llvm-34d380e1f63a7e2cdb9ab1e6498f727fcd710a14.tar.bz2
[IndVars] Add check of loop invariant for indirect use
We usually only check direct use instruction of IV, while the bitcast of 'ptrtoint ptr to i64' doesn't affect the result, so go a step further. Fix https://github.com/llvm/llvm-project/issues/59633. Reviewed By: markoshorro Differential Revision: https://reviews.llvm.org/D151877
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyIndVar.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyIndVar.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
index 62821f1..a28916b 100644
--- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
@@ -908,6 +908,14 @@ void SimplifyIndvar::simplifyUsers(PHINode *CurrIV, IVVisitor *V) {
if (replaceIVUserWithLoopInvariant(UseInst))
continue;
+ // Go further for the bitcast ''prtoint ptr to i64'
+ if (isa<PtrToIntInst>(UseInst))
+ for (Use &U : UseInst->uses()) {
+ Instruction *User = cast<Instruction>(U.getUser());
+ if (replaceIVUserWithLoopInvariant(User))
+ break; // done replacing
+ }
+
Instruction *IVOperand = UseOper.second;
for (unsigned N = 0; IVOperand; ++N) {
assert(N <= Simplified.size() && "runaway iteration");