mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-14 14:24:05 +00:00
Revert patches to add case-range support for PR1255.
The work on this project was left in an unfinished and inconsistent state. Hopefully someone will eventually get a chance to implement this feature, but in the meantime, it is better to put things back the way the were. I have left support in the bitcode reader to handle the case-range bitcode format, so that we do not lose bitcode compatibility with the llvm 3.3 release. This reverts the following commits: 155464, 156374, 156377, 156613, 156704, 156757, 156804 156808, 156985, 157046, 157112, 157183, 157315, 157384, 157575, 157576, 157586, 157612, 157810, 157814, 157815, 157880, 157881, 157882, 157884, 157887, 157901, 158979, 157987, 157989, 158986, 158997, 159076, 159101, 159100, 159200, 159201, 159207, 159527, 159532, 159540, 159583, 159618, 159658, 159659, 159660, 159661, 159703, 159704, 160076, 167356, 172025, 186736 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190328 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -196,33 +196,28 @@ 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();
|
||||
IntegersSubset& Case = FirstCase.getCaseValueEx();
|
||||
if (Case.isSingleNumber()) {
|
||||
// FIXME: Currently work with ConstantInt based numbers.
|
||||
Value *Cond = Builder.CreateICmpEQ(SI->getCondition(),
|
||||
Case.getSingleNumber(0).toConstantInt(),
|
||||
"cond");
|
||||
Value *Cond = Builder.CreateICmpEQ(SI->getCondition(),
|
||||
FirstCase.getCaseValue(), "cond");
|
||||
|
||||
// Insert the new branch.
|
||||
BranchInst *NewBr = Builder.CreateCondBr(Cond,
|
||||
FirstCase.getCaseSuccessor(),
|
||||
SI->getDefaultDest());
|
||||
MDNode* MD = SI->getMetadata(LLVMContext::MD_prof);
|
||||
if (MD && MD->getNumOperands() == 3) {
|
||||
ConstantInt *SICase = dyn_cast<ConstantInt>(MD->getOperand(2));
|
||||
ConstantInt *SIDef = dyn_cast<ConstantInt>(MD->getOperand(1));
|
||||
assert(SICase && SIDef);
|
||||
// The TrueWeight should be the weight for the single case of SI.
|
||||
NewBr->setMetadata(LLVMContext::MD_prof,
|
||||
MDBuilder(BB->getContext()).
|
||||
createBranchWeights(SICase->getValue().getZExtValue(),
|
||||
SIDef->getValue().getZExtValue()));
|
||||
}
|
||||
|
||||
// Delete the old switch.
|
||||
SI->eraseFromParent();
|
||||
return true;
|
||||
// Insert the new branch.
|
||||
BranchInst *NewBr = Builder.CreateCondBr(Cond,
|
||||
FirstCase.getCaseSuccessor(),
|
||||
SI->getDefaultDest());
|
||||
MDNode* MD = SI->getMetadata(LLVMContext::MD_prof);
|
||||
if (MD && MD->getNumOperands() == 3) {
|
||||
ConstantInt *SICase = dyn_cast<ConstantInt>(MD->getOperand(2));
|
||||
ConstantInt *SIDef = dyn_cast<ConstantInt>(MD->getOperand(1));
|
||||
assert(SICase && SIDef);
|
||||
// The TrueWeight should be the weight for the single case of SI.
|
||||
NewBr->setMetadata(LLVMContext::MD_prof,
|
||||
MDBuilder(BB->getContext()).
|
||||
createBranchWeights(SICase->getValue().getZExtValue(),
|
||||
SIDef->getValue().getZExtValue()));
|
||||
}
|
||||
|
||||
// Delete the old switch.
|
||||
SI->eraseFromParent();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user