summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorSanjoy Das <sanjoy@playingwithpointers.com>2016-05-23 22:16:45 +0000
committerSanjoy Das <sanjoy@playingwithpointers.com>2016-05-23 22:16:45 +0000
commitaa83c47bab636a2bd378f614f6958fe8a58eed8b (patch)
tree9b252b57e45e9c1dfd470e4876c036dc509e9304 /llvm/lib
parent90770c7c76574b72c5807c5af87bfc6bec7078d4 (diff)
downloadbcm5719-llvm-aa83c47bab636a2bd378f614f6958fe8a58eed8b.tar.gz
bcm5719-llvm-aa83c47bab636a2bd378f614f6958fe8a58eed8b.zip
[IRCE] Optimize "uses" not branches; NFCI
This changes IRCE to optimize uses, and not branches. This change is NFCI since the uses we do inspect are in practice only ever going to be the condition use in conditional branches; but this flexibility will later allow us to analyze more complex expressions than just a direct branch on a range check. llvm-svn: 270500
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp b/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
index 5b4b6c14693..2b9f3f59c8e 100644
--- a/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
@@ -118,7 +118,7 @@ class InductiveRangeCheck {
const SCEV *Offset;
const SCEV *Scale;
Value *Length;
- BranchInst *Branch;
+ Use *CheckUse;
RangeCheckKind Kind;
static RangeCheckKind parseRangeCheckICmp(Loop *L, ICmpInst *ICI,
@@ -129,8 +129,9 @@ class InductiveRangeCheck {
parseRangeCheck(Loop *L, ScalarEvolution &SE, Value *Condition,
const SCEV *&Index, Value *&UpperLimit);
- InductiveRangeCheck() :
- Offset(nullptr), Scale(nullptr), Length(nullptr), Branch(nullptr) { }
+ InductiveRangeCheck()
+ : Offset(nullptr), Scale(nullptr), Length(nullptr),
+ CheckUse(nullptr) {}
public:
const SCEV *getOffset() const { return Offset; }
@@ -149,9 +150,9 @@ public:
Length->print(OS);
else
OS << "(null)";
- OS << "\n Branch: ";
- getBranch()->print(OS);
- OS << "\n";
+ OS << "\n CheckUse: ";
+ getCheckUse()->getUser()->print(OS);
+ OS << " Operand: " << getCheckUse()->getOperandNo() << "\n";
}
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
@@ -160,7 +161,7 @@ public:
}
#endif
- BranchInst *getBranch() const { return Branch; }
+ Use *getCheckUse() const { return CheckUse; }
/// Represents an signed integer range [Range.getBegin(), Range.getEnd()). If
/// R.getEnd() sle R.getBegin(), then R denotes the empty range.
@@ -407,7 +408,7 @@ InductiveRangeCheck::create(BranchInst *BI, Loop *L, ScalarEvolution &SE,
IRC.Length = Length;
IRC.Offset = IndexAddRec->getStart();
IRC.Scale = IndexAddRec->getStepRecurrence(SE);
- IRC.Branch = BI;
+ IRC.CheckUse = &BI->getOperandUse(0);
IRC.Kind = RCKind;
return IRC;
}
@@ -1474,7 +1475,7 @@ bool InductiveRangeCheckElimination::runOnLoop(Loop *L, LPPassManager &LPM) {
ConstantInt *FoldedRangeCheck = IRC.getPassingDirection()
? ConstantInt::getTrue(Context)
: ConstantInt::getFalse(Context);
- IRC.getBranch()->setCondition(FoldedRangeCheck);
+ IRC.getCheckUse()->set(FoldedRangeCheck);
}
}
OpenPOWER on IntegriCloud