From 04854ab1e5adb48677ba1740e4ffbd929638ec23 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Mon, 18 Jul 2016 19:14:14 +0000 Subject: [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. llvm-svn: 275884 --- llvm/lib/Transforms/Scalar/GVNHoist.cpp | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'llvm/lib/Transforms') diff --git a/llvm/lib/Transforms/Scalar/GVNHoist.cpp b/llvm/lib/Transforms/Scalar/GVNHoist.cpp index c53263ac194..71f992ef8ff 100644 --- a/llvm/lib/Transforms/Scalar/GVNHoist.cpp +++ b/llvm/lib/Transforms/Scalar/GVNHoist.cpp @@ -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; -- cgit v1.2.3