[llvm] 431a40e - [LoopUnswitch] Assert that branch condition is either and/or but not both

Juneyoung Lee via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 30 18:35:31 PDT 2021


Author: Juneyoung Lee
Date: 2021-03-31T10:35:22+09:00
New Revision: 431a40e1e28f181e87dd247b91a5e6872dd64ab4

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

LOG: [LoopUnswitch] Assert that branch condition is either and/or but not both

as suggested at https://reviews.llvm.org/rG5bb38e84d3d0#986321

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
index 2e1c0dee32dc9..d1121ec88ccb9 100644
--- a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
+++ b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
@@ -1995,10 +1995,11 @@ static void unswitchNontrivialInvariants(
   bool Direction = true;
   int ClonedSucc = 0;
   if (!FullUnswitch) {
+    Value *Cond = BI->getCondition();
+    assert((match(Cond, m_LogicalAnd()) ^ match(Cond, m_LogicalOr())) &&
+           "Only `or`, `and`, an `select` instructions can combine "
+           "invariants being unswitched.");
     if (!match(BI->getCondition(), m_LogicalOr())) {
-      assert(match(BI->getCondition(), m_LogicalAnd()) &&
-             "Only `or`, `and`, an `select` instructions can combine "
-             "invariants being unswitched.");
       Direction = false;
       ClonedSucc = 1;
     }


        


More information about the llvm-commits mailing list