From af6721bf068b62e799d041795b487cda728dbf7d Mon Sep 17 00:00:00 2001 From: Aditya Nandakumar Date: Fri, 11 Jul 2014 21:49:39 +0000 Subject: [PATCH] When we sink an instruction, this can open up opportunity for the operands to be sunk - add them to the worklist git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212847 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/InstCombine/InstructionCombining.cpp | 13 +++++++++++-- .../LoopVectorize/runtime-check-readonly.ll | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/Transforms/InstCombine/InstructionCombining.cpp b/lib/Transforms/InstCombine/InstructionCombining.cpp index 08e24461a61..fe3b8b41fdb 100644 --- a/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -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(U.get())) + Worklist.Add(OpI); + } + } } } diff --git a/test/Transforms/LoopVectorize/runtime-check-readonly.ll b/test/Transforms/LoopVectorize/runtime-check-readonly.ll index 01e28bc4466..73b28301b7e 100644 --- a/test/Transforms/LoopVectorize/runtime-check-readonly.ll +++ b/test/Transforms/LoopVectorize/runtime-check-readonly.ll @@ -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 -- 2.49.0