[llvm-commits] [llvm] r133285 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp

Stuart Hastings stuart at apple.com
Fri Jun 17 13:21:52 PDT 2011


Author: stuart
Date: Fri Jun 17 15:21:52 2011
New Revision: 133285

URL: http://llvm.org/viewvc/llvm-project?rev=133285&view=rev
Log:
Relocate NUW test to cover all binary ops in a dynamic alloca expr.
Followup to 132926.  rdar://problem/9265821

Modified:
    llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp

Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp?rev=133285&r1=133284&r2=133285&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp Fri Jun 17 15:21:52 2011
@@ -29,6 +29,10 @@
     return ConstantInt::get(Val->getType(), 0);
   }
   
+  // Insist that the amount-to-allocate not overflow.
+  OverflowingBinaryOperator *OBI = dyn_cast<OverflowingBinaryOperator>(Val);
+  if (OBI && !OBI->hasNoUnsignedWrap()) return 0;
+
   if (BinaryOperator *I = dyn_cast<BinaryOperator>(Val)) {
     if (ConstantInt *RHS = dyn_cast<ConstantInt>(I->getOperand(1))) {
       if (I->getOpcode() == Instruction::Shl) {
@@ -71,11 +75,6 @@
   // This requires TargetData to get the alloca alignment and size information.
   if (!TD) return 0;
 
-  // Insist that the amount-to-allocate not overflow.
-  OverflowingBinaryOperator *OBI =
-    dyn_cast<OverflowingBinaryOperator>(AI.getOperand(0));
-  if (OBI && !(OBI->hasNoSignedWrap() || OBI->hasNoUnsignedWrap())) return 0;
-
   const PointerType *PTy = cast<PointerType>(CI.getType());
   
   BuilderTy AllocaBuilder(*Builder);





More information about the llvm-commits mailing list