Implement InstCombine/2003-08-12-AllocaNonNull.ll

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7807 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2003-08-13 05:38:46 +00:00
parent 934754bed6
commit 3ccd17ea2a

View File

@ -768,10 +768,12 @@ Instruction *InstCombiner::visitSetCondInst(BinaryOperator &I) {
if (Op0 == Op1)
return ReplaceInstUsesWith(I, ConstantBool::get(isTrueWhenEqual(I)));
// setcc <global*>, 0 - Global value addresses are never null!
if (isa<GlobalValue>(Op0) && isa<ConstantPointerNull>(Op1))
// setcc <global/alloca*>, 0 - Global/Stack value addresses are never null!
if (isa<ConstantPointerNull>(Op1) &&
(isa<GlobalValue>(Op0) || isa<AllocaInst>(Op0)))
return ReplaceInstUsesWith(I, ConstantBool::get(!isTrueWhenEqual(I)));
// setcc's with boolean values can always be turned into bitwise operations
if (Ty == Type::BoolTy) {
// If this is <, >, or !=, we can change this into a simple xor instruction