[llvm] r276840 - GVN-hoist: use DFS numbers instead of walking the instruction stream
Sebastian Pop via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 26 22:13:53 PDT 2016
Author: spop
Date: Wed Jul 27 00:13:52 2016
New Revision: 276840
URL: http://llvm.org/viewvc/llvm-project?rev=276840&view=rev
Log:
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
Modified:
llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp?rev=276840&r1=276839&r2=276840&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp Wed Jul 27 00:13:52 2016
@@ -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.
More information about the llvm-commits
mailing list