mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
PR1255(case ranges) related changes in Local Transformations.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157315 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
88097819fc
commit
a2067fbe22
@ -169,16 +169,20 @@ bool llvm::ConstantFoldTerminator(BasicBlock *BB, bool DeleteDeadConditions) {
|
||||
// Otherwise, we can fold this switch into a conditional branch
|
||||
// instruction if it has only one non-default destination.
|
||||
SwitchInst::CaseIt FirstCase = SI->case_begin();
|
||||
Value *Cond = Builder.CreateICmpEQ(SI->getCondition(),
|
||||
FirstCase.getCaseValue(), "cond");
|
||||
ConstantRangesSet CRS = FirstCase.getCaseValueEx();
|
||||
if (CRS.getNumItems() == 1 && CRS.isSingleNumber(0)) {
|
||||
Value *Cond = Builder.CreateICmpEQ(SI->getCondition(),
|
||||
CRS.getItem(0).Low, "cond");
|
||||
|
||||
// Insert the new branch.
|
||||
Builder.CreateCondBr(Cond, FirstCase.getCaseSuccessor(),
|
||||
SI->getDefaultDest());
|
||||
// Insert the new branch.
|
||||
Builder.CreateCondBr(Cond, FirstCase.getCaseSuccessor(),
|
||||
SI->getDefaultDest());
|
||||
|
||||
// Delete the old switch.
|
||||
SI->eraseFromParent();
|
||||
return true;
|
||||
// Delete the old switch.
|
||||
SI->eraseFromParent();
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user