[llvm] r249470 - [IndVars] Extract out eliminateIdentitySCEV, NFC
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 6 14:44:39 PDT 2015
Author: sanjoy
Date: Tue Oct 6 16:44:39 2015
New Revision: 249470
URL: http://llvm.org/viewvc/llvm-project?rev=249470&view=rev
Log:
[IndVars] Extract out eliminateIdentitySCEV, NFC
Summary:
Reflow a comment while at it.
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D13459
Modified:
llvm/trunk/lib/Transforms/Utils/SimplifyIndVar.cpp
Modified: llvm/trunk/lib/Transforms/Utils/SimplifyIndVar.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyIndVar.cpp?rev=249470&r1=249469&r2=249470&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyIndVar.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SimplifyIndVar.cpp Tue Oct 6 16:44:39 2015
@@ -68,6 +68,8 @@ namespace {
Value *foldIVUser(Instruction *UseInst, Instruction *IVOperand);
+ bool eliminateIdentitySCEV(Instruction *UseInst, Instruction *IVOperand);
+
bool eliminateIVUser(Instruction *UseInst, Instruction *IVOperand);
void eliminateIVComparison(ICmpInst *ICmp, Value *IVOperand);
void eliminateIVRemainder(BinaryOperator *Rem, Value *IVOperand,
@@ -277,9 +279,9 @@ void SimplifyIndvar::eliminateIVRemainde
DeadInsts.emplace_back(Rem);
}
-/// Eliminate an operation that consumes a simple IV and has
-/// no observable side-effect given the range of IV values.
-/// IVOperand is guaranteed SCEVable, but UseInst may not be.
+/// Eliminate an operation that consumes a simple IV and has no observable
+/// side-effect given the range of IV values. IVOperand is guaranteed SCEVable,
+/// but UseInst may not be.
bool SimplifyIndvar::eliminateIVUser(Instruction *UseInst,
Instruction *IVOperand) {
if (ICmpInst *ICmp = dyn_cast<ICmpInst>(UseInst)) {
@@ -294,7 +296,15 @@ bool SimplifyIndvar::eliminateIVUser(Ins
}
}
- // Eliminate any operation that SCEV can prove is an identity function.
+ if (eliminateIdentitySCEV(UseInst, IVOperand))
+ return true;
+
+ return false;
+}
+
+/// Eliminate any operation that SCEV can prove is an identity function.
+bool SimplifyIndvar::eliminateIdentitySCEV(Instruction *UseInst,
+ Instruction *IVOperand) {
if (!SE->isSCEVable(UseInst->getType()) ||
(UseInst->getType() != IVOperand->getType()) ||
(SE->getSCEV(UseInst) != SE->getSCEV(IVOperand)))
More information about the llvm-commits
mailing list