diff options
author | David Majnemer <david.majnemer@gmail.com> | 2015-01-04 07:36:02 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2015-01-04 07:36:02 +0000 |
commit | 087dc8b83197db9e0f87885da20feea574343c3f (patch) | |
tree | 454da0ce168c6ec5b8523bbfac026f316c776042 /llvm | |
parent | 6ee8d17bc61d6a7e479b349d7f48edeabe61791f (diff) | |
download | bcm5719-llvm-087dc8b83197db9e0f87885da20feea574343c3f.tar.gz bcm5719-llvm-087dc8b83197db9e0f87885da20feea574343c3f.zip |
InstCombine: match can find ConstantExprs, don't assume we have a Value
We assumed the output of a match was a Value, this would cause us to
assert because we would fail a cast<>. Instead, use a helper in the
Operator family to hide the distinction between Value and Constant.
This fixes PR22087.
llvm-svn: 225127
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp | 4 | ||||
-rw-r--r-- | llvm/test/Transforms/InstCombine/mul.ll | 9 |
2 files changed, 11 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp index 255e5872583..165a9e92654 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp @@ -341,10 +341,10 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) { bool ShlNSW = false; if (match(Op0, m_Shl(m_One(), m_Value(Y)))) { BO = BinaryOperator::CreateShl(Op1, Y); - ShlNSW = cast<BinaryOperator>(Op0)->hasNoSignedWrap(); + ShlNSW = cast<ShlOperator>(Op0)->hasNoSignedWrap(); } else if (match(Op1, m_Shl(m_One(), m_Value(Y)))) { BO = BinaryOperator::CreateShl(Op0, Y); - ShlNSW = cast<BinaryOperator>(Op1)->hasNoSignedWrap(); + ShlNSW = cast<ShlOperator>(Op1)->hasNoSignedWrap(); } if (BO) { if (I.hasNoUnsignedWrap()) diff --git a/llvm/test/Transforms/InstCombine/mul.ll b/llvm/test/Transforms/InstCombine/mul.ll index a81ba726387..4d1e6c700bd 100644 --- a/llvm/test/Transforms/InstCombine/mul.ll +++ b/llvm/test/Transforms/InstCombine/mul.ll @@ -279,3 +279,12 @@ define i64 @test30(i32 %A, i32 %B) { ; CHECK-NEXT: %[[mul:.*]] = mul nuw i64 %[[zext1]], %[[zext2]] ; CHECK-NEXT: ret i64 %[[mul]] } + +@PR22087 = external global i32 +define i32 @test31(i32 %V) { +; CHECK-LABEL: @test31 + %mul = mul i32 %V, shl (i32 1, i32 zext (i1 icmp ne (i32* inttoptr (i64 1 to i32*), i32* @PR22087) to i32)) + ret i32 %mul +; CHECK: %[[mul:.*]] = shl i32 %V, zext (i1 icmp ne (i32* inttoptr (i64 1 to i32*), i32* @PR22087) to i32) +; CHECK-NEXT: ret i32 %[[mul]] +} |