mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-22 11:39:35 +00:00
PR1255(case ranges) related changes in Local Transformations.
llvm-svn: 157315
This commit is contained in:
parent
49c52dde2b
commit
49092667b1
@ -169,8 +169,10 @@ 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();
|
||||
ConstantRangesSet CRS = FirstCase.getCaseValueEx();
|
||||
if (CRS.getNumItems() == 1 && CRS.isSingleNumber(0)) {
|
||||
Value *Cond = Builder.CreateICmpEQ(SI->getCondition(),
|
||||
FirstCase.getCaseValue(), "cond");
|
||||
CRS.getItem(0).Low, "cond");
|
||||
|
||||
// Insert the new branch.
|
||||
Builder.CreateCondBr(Cond, FirstCase.getCaseSuccessor(),
|
||||
@ -179,6 +181,8 @@ bool llvm::ConstantFoldTerminator(BasicBlock *BB, bool DeleteDeadConditions) {
|
||||
// Delete the old switch.
|
||||
SI->eraseFromParent();
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user