diff options
| author | Chris Lattner <sabre@nondot.org> | 2002-05-09 20:11:54 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2002-05-09 20:11:54 +0000 |
| commit | 1fc23f382e4bdb2df4305cd00057856b7572d74b (patch) | |
| tree | 1e60809a3be766bfc855723a66ae9cd9346ac65e /llvm/lib/Transforms | |
| parent | 6bd7ac620526d9f83465f5f072dc4645c334c683 (diff) | |
| download | bcm5719-llvm-1fc23f382e4bdb2df4305cd00057856b7572d74b.tar.gz bcm5719-llvm-1fc23f382e4bdb2df4305cd00057856b7572d74b.zip | |
Handle setcc <global*>, 0 instructions, Global pointers are never null!
llvm-svn: 2582
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index 9625398017a..385c07004d4 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp @@ -343,17 +343,31 @@ Instruction *InstCombiner::visitXor(BinaryOperator *I) { 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) { if (I->use_empty()) return 0; // Don't fix dead instructions... bool Changed = SimplifyBinOp(I); // setcc X, X 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 - 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; } |

