@@ -1058,18 +1058,15 @@ bool IRTranslator::lowerJumpTableWorkItem(SwitchCG::SwitchWorkListItem W,
10581058 }
10591059 return true ;
10601060}
1061- bool IRTranslator::lowerSwitchRangeWorkItem (SwitchCG::CaseClusterIt I,
1062- Value *Cond,
1063- MachineBasicBlock *Fallthrough,
1064- bool FallthroughUnreachable,
1065- BranchProbability UnhandledProbs,
1066- MachineBasicBlock *CurMBB,
1067- MachineIRBuilder &MIB,
1068- MachineBasicBlock *SwitchMBB) {
1061+ bool IRTranslator::lowerSwitchAndOrRangeWorkItem (
1062+ SwitchCG::CaseClusterIt I, Value *Cond, MachineBasicBlock *Fallthrough,
1063+ bool FallthroughUnreachable, BranchProbability UnhandledProbs,
1064+ MachineBasicBlock *CurMBB, MachineIRBuilder &MIB,
1065+ MachineBasicBlock *SwitchMBB) {
10691066 using namespace SwitchCG ;
10701067 const Value *RHS, *LHS, *MHS;
10711068 CmpInst::Predicate Pred;
1072- if (I->Low == I->High ) {
1069+ if (I->Low == I->High || I-> Kind == CC_And ) {
10731070 // Check Cond == I->Low.
10741071 Pred = CmpInst::ICMP_EQ;
10751072 LHS = Cond;
@@ -1087,6 +1084,7 @@ bool IRTranslator::lowerSwitchRangeWorkItem(SwitchCG::CaseClusterIt I,
10871084 // The false probability is the sum of all unhandled cases.
10881085 CaseBlock CB (Pred, FallthroughUnreachable, LHS, RHS, MHS, I->MBB , Fallthrough,
10891086 CurMBB, MIB.getDebugLoc (), I->Prob , UnhandledProbs);
1087+ CB.EmitAnd = I->Kind == CC_And;
10901088
10911089 emitSwitchCase (CB, SwitchMBB, MIB);
10921090 return true ;
@@ -1326,10 +1324,11 @@ bool IRTranslator::lowerSwitchWorkItem(SwitchCG::SwitchWorkListItem W,
13261324 }
13271325 break ;
13281326 }
1327+ case CC_And:
13291328 case CC_Range: {
1330- if (!lowerSwitchRangeWorkItem (I, Cond, Fallthrough,
1331- FallthroughUnreachable, UnhandledProbs,
1332- CurMBB, MIB, SwitchMBB)) {
1329+ if (!lowerSwitchAndOrRangeWorkItem (I, Cond, Fallthrough,
1330+ FallthroughUnreachable, UnhandledProbs,
1331+ CurMBB, MIB, SwitchMBB)) {
13331332 LLVM_DEBUG (dbgs () << " Failed to lower switch range" );
13341333 return false ;
13351334 }
0 commit comments