summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorStuart Hastings <stuart@apple.com>2011-06-17 20:21:52 +0000
committerStuart Hastings <stuart@apple.com>2011-06-17 20:21:52 +0000
commit3761c34e03a1220f0cc2ee7df31feeec5ee7e15c (patch)
tree1c3de03680a075f1992b145df1f79bb243217584 /lib
parented6fa188c4cf2d382991dd054f7c5157420908c3 (diff)
downloadllvm-3761c34e03a1220f0cc2ee7df31feeec5ee7e15c.tar.gz
llvm-3761c34e03a1220f0cc2ee7df31feeec5ee7e15c.tar.bz2
llvm-3761c34e03a1220f0cc2ee7df31feeec5ee7e15c.tar.xz
Relocate NUW test to cover all binary ops in a dynamic alloca expr.
Followup to 132926. rdar://problem/9265821 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133285 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/InstCombine/InstCombineCasts.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineCasts.cpp b/lib/Transforms/InstCombine/InstCombineCasts.cpp
index 601d9b42f3..48a747d764 100644
--- a/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ b/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -29,6 +29,10 @@ static Value *DecomposeSimpleLinearExpr(Value *Val, unsigned &Scale,
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 @@ Instruction *InstCombiner::PromoteCastOfAllocation(BitCastInst &CI,
// 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);