Implement InstCombine/2003-08-12-AllocaNonNull.ll
authorChris Lattner <sabre@nondot.org>
Wed, 13 Aug 2003 05:38:46 +0000 (05:38 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 13 Aug 2003 05:38:46 +0000 (05:38 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7807 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp

index d2d8c93b5f74178deb35267bd79c8c433a6ba4d0..8a3c0d47e97f0b41c51b77244a9203644c240639 100644 (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