From: Juneyoung Lee Date: Wed, 31 Mar 2021 01:34:46 +0000 (+0900) Subject: [LoopUnswitch] Assert that branch condition is either and/or but not both X-Git-Tag: llvmorg-14-init~10846 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=431a40e1e28f181e87dd247b91a5e6872dd64ab4;p=platform%2Fupstream%2Fllvm.git [LoopUnswitch] Assert that branch condition is either and/or but not both as suggested at https://reviews.llvm.org/rG5bb38e84d3d0#986321 --- diff --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp index 2e1c0de..d1121ec 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; }