Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.731 -> 1.732
---
Log message:

implement Transforms/InstCombine/malloc2.ll and PR1313: http://llvm.org/PR1313 


---
Diffs of the changes:  (+11 -1)

 InstructionCombining.cpp |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletion(-)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.731 
llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.732
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.731   Wed Apr  4 
14:16:42 2007
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Fri Apr  6 13:57:34 2007
@@ -4744,7 +4744,7 @@
         if (Instruction *NV = FoldOpIntoPhi(I))
           return NV;
         break;
-      case Instruction::Select:
+      case Instruction::Select: {
         // If either operand of the select is a constant, we can fold the
         // comparison into the select arms, which will cause one to be
         // constant folded and the select turned into a bitwise or.
@@ -4771,6 +4771,16 @@
           return new SelectInst(LHSI->getOperand(0), Op1, Op2);
         break;
       }
+      case Instruction::Malloc:
+        // If we have (malloc != null), and if the malloc has a single use, we
+        // can assume it is successful and remove the malloc.
+        if (LHSI->hasOneUse() && isa<ConstantPointerNull>(RHSC)) {
+          AddToWorkList(LHSI);
+          return ReplaceInstUsesWith(I, ConstantInt::get(Type::Int1Ty,
+                                                         !isTrueWhenEqual(I)));
+        }
+        break;
+      }
   }
 
   // If we can optimize a 'icmp GEP, P' or 'icmp P, GEP', do so now.



_______________________________________________
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

Reply via email to