[PATCH] D30116: Refactor SimplifyCFG:canSinkInstructions [NFC]

Aditya Kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 1 09:44:22 PST 2017


hiraditya added a comment.

This patch is only to move the code around to avoid + avoid redundant computations.



================
Comment at: llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1454
   const Instruction *I0 = Insts.front();
-  for (auto *I : Insts)
+  for (Instruction *I : Insts)
     if (!I->isSameOperationAs(I0))
----------------
jmolloy wrote:
> Why?
I can remove this if you want.


================
Comment at: llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1488
-    // https://llvm.org/bugs/show_bug.cgi?id=30188
-    if (OI == 1 && isa<StoreInst>(I0) &&
-        any_of(Insts, [](const Instruction *I) {
----------------
jmolloy wrote:
> Your new code is ignoring the operand index, so is more conservative than the old code.
This code will only execute when IO is a store instruction. And stores have 2 operands, so that implies OI=1 is not needed when we hoist this code out of the loop. It appears OI==1 check was there because for stores second operand is the pointer operand, and for stores first operand (OI==0) is the pointer operand.


https://reviews.llvm.org/D30116





More information about the llvm-commits mailing list