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 | 70635adea36679b98bbc87f196548ed42a244a29 (patch) | |
| tree | fe7af1cafc273d136789464171d779f9a5062fe3 /llvm/test/Transforms/InstCombine/sub.ll | |
| parent | 441042796d90a9319804efa16586a84786801525 (diff) | |
| download | bcm5719-llvm-70635adea36679b98bbc87f196548ed42a244a29.tar.gz bcm5719-llvm-70635adea36679b98bbc87f196548ed42a244a29.zip | |
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.
llvm-svn: 60275
Diffstat (limited to 'llvm/test/Transforms/InstCombine/sub.ll')
| -rw-r--r-- | llvm/test/Transforms/InstCombine/sub.ll | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/llvm/test/Transforms/InstCombine/sub.ll b/llvm/test/Transforms/InstCombine/sub.ll index da6d710f6bc..1ab4eaf1b49 100644 --- a/llvm/test/Transforms/InstCombine/sub.ll +++ b/llvm/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 } |

