summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorSebastian Pop <sebpop@gmail.com>2016-07-27 05:13:52 +0000
committerSebastian Pop <sebpop@gmail.com>2016-07-27 05:13:52 +0000
commit586d3eaeb59c20f95b1ac89ba53ffca2ddca3866 (patch)
treed9e85b36621eb09178620ddf8f2bdf5e7df28a1e /llvm/lib/Transforms
parent7855719c102ef1440fb846dec6716e263d64efdc (diff)
downloadbcm5719-llvm-586d3eaeb59c20f95b1ac89ba53ffca2ddca3866.tar.gz
bcm5719-llvm-586d3eaeb59c20f95b1ac89ba53ffca2ddca3866.zip
GVN-hoist: use DFS numbers instead of walking the instruction stream
The patch replaces a function that walks the IR with a call to firstInBB() that uses the DFS numbering. NFC. Differential Revision: https://reviews.llvm.org/D22809 llvm-svn: 276840
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/GVNHoist.cpp13
1 files changed, 3 insertions, 10 deletions
diff --git a/llvm/lib/Transforms/Scalar/GVNHoist.cpp b/llvm/lib/Transforms/Scalar/GVNHoist.cpp
index 8251a481e97..6b9142f6a7d 100644
--- a/llvm/lib/Transforms/Scalar/GVNHoist.cpp
+++ b/llvm/lib/Transforms/Scalar/GVNHoist.cpp
@@ -609,13 +609,6 @@ private:
return true;
}
- Instruction *firstOfTwo(Instruction *I, Instruction *J) const {
- for (Instruction &I1 : *I->getParent())
- if (&I1 == I || &I1 == J)
- return &I1;
- llvm_unreachable("Both I and J must be from same BB");
- }
-
bool makeOperandsAvailable(Instruction *Repl, BasicBlock *HoistPt,
const SmallVecInsn &InstructionsToHoist) const {
// Check whether the GEP of a ld/st can be synthesized at HoistPt.
@@ -685,12 +678,12 @@ private:
const SmallVecInsn &InstructionsToHoist = HP.second;
Instruction *Repl = nullptr;
for (Instruction *I : InstructionsToHoist)
- if (I->getParent() == HoistPt) {
+ if (I->getParent() == HoistPt)
// If there are two instructions in HoistPt to be hoisted in place:
// update Repl to be the first one, such that we can rename the uses
// of the second based on the first.
- Repl = !Repl ? I : firstOfTwo(Repl, I);
- }
+ if (!Repl || firstInBB(I, Repl))
+ Repl = I;
if (Repl) {
// Repl is already in HoistPt: it remains in place.
OpenPOWER on IntegriCloud