diff options
author | Bill Wendling <isanbard@gmail.com> | 2008-11-30 03:42:12 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2008-11-30 03:42:12 +0000 |
commit | e1196d6d3efabfc58103acc9076ad946d3574a04 (patch) | |
tree | cf179d0e8850608a3ca59d46b4729c512df0d6cf /test/Transforms/InstCombine/sub.ll | |
parent | 4a69bade2385022ca776edc22150f3b750cdf23c (diff) |
Instcombine was illegally transforming -X/C into X/-C when either X or C
overflowed on negation. This commit checks to make sure that neithe C nor X
overflows. This requires that the RHS of X (a subtract instruction) be a
constant integer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60275 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/InstCombine/sub.ll')
-rw-r--r-- | test/Transforms/InstCombine/sub.ll | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/test/Transforms/InstCombine/sub.ll b/test/Transforms/InstCombine/sub.ll index da6d710f6bc..1ab4eaf1b49 100644 --- a/test/Transforms/InstCombine/sub.ll +++ b/test/Transforms/InstCombine/sub.ll @@ -1,7 +1,7 @@ ; This test makes sure that these instructions are properly eliminated. ; ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \ -; RUN: grep -v {sub i32 %Cok, %Bok} | not grep sub +; RUN: grep -v {sub i32 %Cok, %Bok} | grep -v {sub i32 0, %Aok} | not grep sub define i32 @test1(i32 %A) { %B = sub i32 %A, %A ; <i32> [#uses=1] @@ -104,8 +104,10 @@ define i32 @test16(i32 %A) { ret i32 %Y } -define i32 @test17(i32 %A) { - %B = sub i32 0, %A ; <i32> [#uses=1] +; Can't fold subtract here because negation it might oveflow. +; PR3142 +define i32 @test17(i32 %Aok) { + %B = sub i32 0, %Aok ; <i32> [#uses=1] %C = sdiv i32 %B, 1234 ; <i32> [#uses=1] ret i32 %C } |