forked from OSchip/llvm-project
Add trivial optimizations for select instructions
llvm-svn: 12317
This commit is contained in:
parent
65a64e1e7a
commit
b909e8b0d4
|
|
@ -108,6 +108,7 @@ namespace {
|
|||
Instruction *visitSetCondInst(BinaryOperator &I);
|
||||
Instruction *visitShiftInst(ShiftInst &I);
|
||||
Instruction *visitCastInst(CastInst &CI);
|
||||
Instruction *visitSelectInst(SelectInst &CI);
|
||||
Instruction *visitCallInst(CallInst &CI);
|
||||
Instruction *visitInvokeInst(InvokeInst &II);
|
||||
Instruction *visitPHINode(PHINode &PN);
|
||||
|
|
@ -1931,6 +1932,20 @@ Instruction *InstCombiner::visitCastInst(CastInst &CI) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
Instruction *InstCombiner::visitSelectInst(SelectInst &SI) {
|
||||
if (ConstantBool *C = dyn_cast<ConstantBool>(SI.getCondition()))
|
||||
if (C == ConstantBool::True)
|
||||
return ReplaceInstUsesWith(SI, SI.getTrueValue());
|
||||
else {
|
||||
assert(C == ConstantBool::False);
|
||||
return ReplaceInstUsesWith(SI, SI.getFalseValue());
|
||||
}
|
||||
// Other transformations are possible!
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// CallInst simplification
|
||||
//
|
||||
Instruction *InstCombiner::visitCallInst(CallInst &CI) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue