[llvm] r275884 - [GVNHoist] Remove a home-grown version of replaceUsesOfWith
David Majnemer via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 18 12:14:14 PDT 2016
Author: majnemer
Date: Mon Jul 18 14:14:14 2016
New Revision: 275884
URL: http://llvm.org/viewvc/llvm-project?rev=275884&view=rev
Log:
[GVNHoist] Remove a home-grown version of replaceUsesOfWith
replaceUsesOfWith will, on average, consider fewer values when trying
to do the replacement.
No functional change is intended.
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=275884&r1=275883&r2=275884&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp Mon Jul 18 14:14:14 2016
@@ -574,19 +574,6 @@ public:
llvm_unreachable("Both I and J must be from same BB");
}
- // Replace the use of From with To in Insn.
- void replaceUseWith(Instruction *Insn, Value *From, Value *To) const {
- for (Value::use_iterator UI = From->use_begin(), UE = From->use_end();
- UI != UE;) {
- Use &U = *UI++;
- if (U.getUser() == Insn) {
- U.set(To);
- return;
- }
- }
- llvm_unreachable("should replace exactly once");
- }
-
bool makeOperandsAvailable(Instruction *Repl, BasicBlock *HoistPt) const {
// Check whether the GEP of a ld/st can be synthesized at HoistPt.
Instruction *Gep = nullptr;
@@ -612,13 +599,13 @@ public:
// Copy the gep before moving the ld/st.
Instruction *ClonedGep = Gep->clone();
ClonedGep->insertBefore(HoistPt->getTerminator());
- replaceUseWith(Repl, Gep, ClonedGep);
+ Repl->replaceUsesOfWith(Gep, ClonedGep);
// Also copy Val.
if (Val) {
Instruction *ClonedVal = Val->clone();
ClonedVal->insertBefore(HoistPt->getTerminator());
- replaceUseWith(Repl, Val, ClonedVal);
+ Repl->replaceUsesOfWith(Val, ClonedVal);
}
return true;
More information about the llvm-commits
mailing list