[llvm] r212847 - When we sink an instruction, this can open up opportunity for the operands to be sunk - add them to the worklist

Aditya Nandakumar aditya_nandakumar at apple.com
Fri Jul 11 14:49:40 PDT 2014


Author: aditya_nandakumar
Date: Fri Jul 11 16:49:39 2014
New Revision: 212847

URL: http://llvm.org/viewvc/llvm-project?rev=212847&view=rev
Log:
When we sink an instruction, this can open up opportunity for the operands to be sunk - add them to the worklist

Modified:
    llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
    llvm/trunk/test/Transforms/LoopVectorize/runtime-check-readonly.ll

Modified: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp?rev=212847&r1=212846&r2=212847&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp Fri Jul 11 16:49:39 2014
@@ -2730,9 +2730,18 @@ bool InstCombiner::DoOneIteration(Functi
         // If the user is one of our immediate successors, and if that successor
         // only has us as a predecessors (we'd have to split the critical edge
         // otherwise), we can keep going.
-        if (UserIsSuccessor && UserParent->getSinglePredecessor())
+        if (UserIsSuccessor && UserParent->getSinglePredecessor()) {
           // Okay, the CFG is simple enough, try to sink this instruction.
-          MadeIRChange |= TryToSinkInstruction(I, UserParent);
+          if (TryToSinkInstruction(I, UserParent)) {
+            MadeIRChange = true;
+            // We'll add uses of the sunk instruction below, but since sinking
+            // can expose opportunities for it's *operands* add them to the
+            // worklist
+            for (Use &U : I->operands())
+              if (Instruction *OpI = dyn_cast<Instruction>(U.get()))
+                Worklist.Add(OpI);
+          }
+        }
       }
     }
 

Modified: llvm/trunk/test/Transforms/LoopVectorize/runtime-check-readonly.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopVectorize/runtime-check-readonly.ll?rev=212847&r1=212846&r2=212847&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LoopVectorize/runtime-check-readonly.ll (original)
+++ llvm/trunk/test/Transforms/LoopVectorize/runtime-check-readonly.ll Fri Jul 11 16:49:39 2014
@@ -7,7 +7,7 @@ target triple = "x86_64-apple-macosx10.8
 ;CHECK: br
 ;CHECK: br
 ;CHECK: getelementptr
-;CHECK-NEXT: getelementptr
+;CHECK-DAG: getelementptr
 ;CHECK-DAG: icmp uge
 ;CHECK-DAG: icmp uge
 ;CHECK-DAG: icmp uge





More information about the llvm-commits mailing list