diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2018-04-05 17:40:51 +0000 |
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2018-04-05 17:40:51 +0000 |
| commit | 37248d35c3a0fe009a72d67ae8a6c734a416bc36 (patch) | |
| tree | 58950805359e4ea9bb4320e30620e7219e24d09e /llvm/test/Transforms | |
| parent | 7f6f43fa3e2fd7c45df1b42757c2b7791e0b5d85 (diff) | |
| download | bcm5719-llvm-37248d35c3a0fe009a72d67ae8a6c734a416bc36.tar.gz bcm5719-llvm-37248d35c3a0fe009a72d67ae8a6c734a416bc36.zip | |
[InstCombine] add test for fneg+fsub with nsz; NFC
There used to be a fold that would handle this case more generally,
but it was removed at rL73243 to fix PR4374:
https://bugs.llvm.org/show_bug.cgi?id=4374
llvm-svn: 329322
Diffstat (limited to 'llvm/test/Transforms')
| -rw-r--r-- | llvm/test/Transforms/InstCombine/fsub.ll | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/llvm/test/Transforms/InstCombine/fsub.ll b/llvm/test/Transforms/InstCombine/fsub.ll index 9323a2dd772..2e5b7fb48bd 100644 --- a/llvm/test/Transforms/InstCombine/fsub.ll +++ b/llvm/test/Transforms/InstCombine/fsub.ll @@ -3,17 +3,31 @@ ; PR4374 -define float @test1(float %a, float %b) { +define float @test1(float %x, float %y) { ; CHECK-LABEL: @test1( -; CHECK-NEXT: [[T1:%.*]] = fsub float [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[T1:%.*]] = fsub float [[X:%.*]], [[Y:%.*]] ; CHECK-NEXT: [[T2:%.*]] = fsub float -0.000000e+00, [[T1]] ; CHECK-NEXT: ret float [[T2]] ; - %t1 = fsub float %a, %b + %t1 = fsub float %x, %y %t2 = fsub float -0.0, %t1 ret float %t2 } +; FIXME: Can't do anything with the test above because -0.0 - 0.0 = -0.0, but if we have nsz: +; -(X - Y) --> Y - X + +define float @neg_sub(float %x, float %y) { +; CHECK-LABEL: @neg_sub( +; CHECK-NEXT: [[T1:%.*]] = fsub float [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[T2:%.*]] = fsub nsz float -0.000000e+00, [[T1]] +; CHECK-NEXT: ret float [[T2]] +; + %t1 = fsub float %x, %y + %t2 = fsub nsz float -0.0, %t1 + ret float %t2 +} + ; <rdar://problem/7530098> define double @test2(double %x, double %y) { |

