When we sink an instruction, this can open up opportunity for the operands to be...
authorAditya Nandakumar <aditya_nandakumar@apple.com>
Fri, 11 Jul 2014 21:49:39 +0000 (21:49 +0000)
committerAditya Nandakumar <aditya_nandakumar@apple.com>
Fri, 11 Jul 2014 21:49:39 +0000 (21:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212847 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/InstCombine/InstructionCombining.cpp
test/Transforms/LoopVectorize/runtime-check-readonly.ll

index 08e24461a610fdfa1086eb2ebff666cf6d225fea..fe3b8b41fdba4ffea041622efe20e437c141b260 100644 (file)
@@ -2730,9 +2730,18 @@ bool InstCombiner::DoOneIteration(Function &F, unsigned Iteration) {
         // 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);
+          }
+        }
       }
     }
 
index 01e28bc4466580615516d0a2eccc7b73c6a413b6..73b28301b7e733e01cae9820c1a464e18c5d310f 100644 (file)
@@ -7,7 +7,7 @@ target triple = "x86_64-apple-macosx10.8.0"
 ;CHECK: br
 ;CHECK: br
 ;CHECK: getelementptr
-;CHECK-NEXT: getelementptr
+;CHECK-DAG: getelementptr
 ;CHECK-DAG: icmp uge
 ;CHECK-DAG: icmp uge
 ;CHECK-DAG: icmp uge