[llvm] e47c101 - [InstCombine][NFC] Simplify check in sinking

Max Kazantsev via llvm-commits llvm-commits at lists.llvm.org
Mon May 18 04:18:02 PDT 2020


Author: Max Kazantsev
Date: 2020-05-18T18:10:40+07:00
New Revision: e47c101e35fd8d046f7d4fa296c17db508e8cdc2

URL: https://github.com/llvm/llvm-project/commit/e47c101e35fd8d046f7d4fa296c17db508e8cdc2
DIFF: https://github.com/llvm/llvm-project/commit/e47c101e35fd8d046f7d4fa296c17db508e8cdc2.diff

LOG: [InstCombine][NFC] Simplify check in sinking

We just need to check that the only predecessor of user parent is
BB, we don't need to iterate through BB's successors for it.

Added: 
    

Modified: 
    llvm/lib/Transforms/InstCombine/InstructionCombining.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index afdff9141e69..247bebd48932 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -3433,19 +3433,9 @@ bool InstCombiner::run() {
           UserParent = UserInst->getParent();
 
         if (UserParent != BB) {
-          bool UserIsSuccessor = false;
-          // See if the user is one of our successors.
-          for (succ_iterator SI = succ_begin(BB), E = succ_end(BB); SI != E;
-               ++SI)
-            if (*SI == UserParent) {
-              UserIsSuccessor = true;
-              break;
-            }
-
-          // 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->getUniquePredecessor()) {
+          // See if the user is one of our successors that has only one
+          // predecessor, so that we don't have to split the critical edge.
+          if (UserParent->getUniquePredecessor() == BB) {
             // Okay, the CFG is simple enough, try to sink this instruction.
             if (TryToSinkInstruction(I, UserParent)) {
               LLVM_DEBUG(dbgs() << "IC: Sink: " << *I << '\n');


        


More information about the llvm-commits mailing list