mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-18 13:34:04 +00:00
Handle setcc <global*>, 0 instructions, Global pointers are never null!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2582 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0aa7cd605d
commit
53a5b57737
@ -343,17 +343,31 @@ Instruction *InstCombiner::visitXor(BinaryOperator *I) {
|
|||||||
return Changed ? I : 0;
|
return Changed ? I : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// isTrueWhenEqual - Return true if the specified setcondinst instruction is
|
||||||
|
// true when both operands are equal...
|
||||||
|
//
|
||||||
|
static bool isTrueWhenEqual(Instruction *I) {
|
||||||
|
return I->getOpcode() == Instruction::SetEQ ||
|
||||||
|
I->getOpcode() == Instruction::SetGE ||
|
||||||
|
I->getOpcode() == Instruction::SetLE;
|
||||||
|
}
|
||||||
|
|
||||||
Instruction *InstCombiner::visitSetCondInst(BinaryOperator *I) {
|
Instruction *InstCombiner::visitSetCondInst(BinaryOperator *I) {
|
||||||
if (I->use_empty()) return 0; // Don't fix dead instructions...
|
if (I->use_empty()) return 0; // Don't fix dead instructions...
|
||||||
bool Changed = SimplifyBinOp(I);
|
bool Changed = SimplifyBinOp(I);
|
||||||
|
|
||||||
// setcc X, X
|
// setcc X, X
|
||||||
if (I->getOperand(0) == I->getOperand(1)) {
|
if (I->getOperand(0) == I->getOperand(1)) {
|
||||||
bool NewVal = I->getOpcode() == Instruction::SetEQ ||
|
|
||||||
I->getOpcode() == Instruction::SetGE ||
|
|
||||||
I->getOpcode() == Instruction::SetLE;
|
|
||||||
AddUsesToWorkList(I); // Add all modified instrs to worklist
|
AddUsesToWorkList(I); // Add all modified instrs to worklist
|
||||||
I->replaceAllUsesWith(ConstantBool::get(NewVal));
|
I->replaceAllUsesWith(ConstantBool::get(isTrueWhenEqual(I)));
|
||||||
|
return I;
|
||||||
|
}
|
||||||
|
|
||||||
|
// setcc <global*>, 0 - Global value addresses are never null!
|
||||||
|
if (isa<GlobalValue>(I->getOperand(0)) &&
|
||||||
|
isa<ConstantPointerNull>(I->getOperand(1))) {
|
||||||
|
AddUsesToWorkList(I); // Add all modified instrs to worklist
|
||||||
|
I->replaceAllUsesWith(ConstantBool::get(!isTrueWhenEqual(I)));
|
||||||
return I;
|
return I;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user