[LoopUnswitch] Add an else clause to IsTrivialUnswitchCondition() when checking Heade...
authorChen Li <meloli87@gmail.com>
Wed, 15 Jul 2015 22:41:13 +0000 (22:41 +0000)
committerChen Li <meloli87@gmail.com>
Wed, 15 Jul 2015 22:41:13 +0000 (22:41 +0000)
Summary:
This is a trivial code change with no functionality effect.

When LoopUnswitch determines trivial unswitch condition, it checks whether the loop header's terminator instruction is a branch instruction or switch instruction since trivial unswitch condition can only apply to these two instruction types. The current code does not fail the check directly on other instruction types, but check the nullness of LoopExitBB variable instead. The added else clause makes the check fail immediately on other instruction types and makes the code more obvious.

Reviewers: reames

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D11239

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242345 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/LoopUnswitch.cpp

index cbc563bd8998faf04515c7dd44d6e1ba4e313897..ce167d1c657ee5ad7cc105e8bd1689c996affca0 100644 (file)
@@ -641,7 +641,8 @@ bool LoopUnswitch::IsTrivialUnswitchCondition(Value *Cond, Constant **Val,
         break;
       }
     }
         break;
       }
     }
-  }
+  } else
+         return false;
 
   // If we didn't find a single unique LoopExit block, or if the loop exit block
   // contains phi nodes, this isn't trivial.
 
   // If we didn't find a single unique LoopExit block, or if the loop exit block
   // contains phi nodes, this isn't trivial.