diff options
author | zhongyunde <zhongyunde@huawei.com> | 2022-07-14 19:40:49 +0800 |
---|---|---|
committer | zhongyunde <zhongyunde@huawei.com> | 2022-07-14 19:41:07 +0800 |
commit | fc6092fd4d138834ba310a8e635770de79276f93 (patch) | |
tree | 2f299b69918ee962b5a550dc07dc82828d2da1e2 /llvm/lib/Transforms/Utils/SimplifyIndVar.cpp | |
parent | e0c66c699eb000f604e24b1c4e73b899b4d942d3 (diff) | |
download | llvm-fc6092fd4d138834ba310a8e635770de79276f93.zip llvm-fc6092fd4d138834ba310a8e635770de79276f93.tar.gz llvm-fc6092fd4d138834ba310a8e635770de79276f93.tar.bz2 |
[IndVars] Eliminate redundant type cast between unsigned integer and float
Extend for unsigned integer according the comment of D129191.
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D129358
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyIndVar.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyIndVar.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp index af15e0c..dde5ecc 100644 --- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp @@ -688,11 +688,15 @@ bool SimplifyIndvar::replaceFloatIVWithIntegerIV(Instruction *UseInst) { unsigned DestNumSigBits = UseInst->getType()->getFPMantissaWidth(); if (IVRange.getActiveBits() <= DestNumSigBits) { for (User *U : UseInst->users()) { - // Match for fptosi of sitofp and with same type. - auto *CI = dyn_cast<FPToSIInst>(U); + // Match for fptosi/fptoui of sitofp and with same type. + auto *CI = dyn_cast<CastInst>(U); if (!CI || IVOperand->getType() != CI->getType()) continue; + CastInst::CastOps Opcode = CI->getOpcode(); + if (Opcode != CastInst::FPToSI && Opcode != CastInst::FPToUI) + continue; + CI->replaceAllUsesWith(IVOperand); DeadInsts.push_back(CI); LLVM_DEBUG(dbgs() << "INDVARS: Replace IV user: " << *CI |