@@ -1059,18 +1059,15 @@ bool IRTranslator::lowerJumpTableWorkItem(SwitchCG::SwitchWorkListItem W,
10591059 }
10601060 return true ;
10611061}
1062- bool IRTranslator::lowerSwitchRangeWorkItem (SwitchCG::CaseClusterIt I,
1063- Value *Cond,
1064- MachineBasicBlock *Fallthrough,
1065- bool FallthroughUnreachable,
1066- BranchProbability UnhandledProbs,
1067- MachineBasicBlock *CurMBB,
1068- MachineIRBuilder &MIB,
1069- MachineBasicBlock *SwitchMBB) {
1062+ bool IRTranslator::lowerSwitchAndOrRangeWorkItem (
1063+ SwitchCG::CaseClusterIt I, Value *Cond, MachineBasicBlock *Fallthrough,
1064+ bool FallthroughUnreachable, BranchProbability UnhandledProbs,
1065+ MachineBasicBlock *CurMBB, MachineIRBuilder &MIB,
1066+ MachineBasicBlock *SwitchMBB) {
10701067 using namespace SwitchCG ;
10711068 const Value *RHS, *LHS, *MHS;
10721069 CmpInst::Predicate Pred;
1073- if (I->Low == I->High ) {
1070+ if (I->Low == I->High || I-> Kind == CC_And ) {
10741071 // Check Cond == I->Low.
10751072 Pred = CmpInst::ICMP_EQ;
10761073 LHS = Cond;
@@ -1088,6 +1085,7 @@ bool IRTranslator::lowerSwitchRangeWorkItem(SwitchCG::CaseClusterIt I,
10881085 // The false probability is the sum of all unhandled cases.
10891086 CaseBlock CB (Pred, FallthroughUnreachable, LHS, RHS, MHS, I->MBB , Fallthrough,
10901087 CurMBB, MIB.getDebugLoc (), I->Prob , UnhandledProbs);
1088+ CB.EmitAnd = I->Kind == CC_And;
10911089
10921090 emitSwitchCase (CB, SwitchMBB, MIB);
10931091 return true ;
@@ -1327,10 +1325,11 @@ bool IRTranslator::lowerSwitchWorkItem(SwitchCG::SwitchWorkListItem W,
13271325 }
13281326 break ;
13291327 }
1328+ case CC_And:
13301329 case CC_Range: {
1331- if (!lowerSwitchRangeWorkItem (I, Cond, Fallthrough,
1332- FallthroughUnreachable, UnhandledProbs,
1333- CurMBB, MIB, SwitchMBB)) {
1330+ if (!lowerSwitchAndOrRangeWorkItem (I, Cond, Fallthrough,
1331+ FallthroughUnreachable, UnhandledProbs,
1332+ CurMBB, MIB, SwitchMBB)) {
13341333 LLVM_DEBUG (dbgs () << " Failed to lower switch range" );
13351334 return false ;
13361335 }
0 commit comments