diff options
author | Sanjay Patel <spatel@rotateright.com> | 2018-04-06 17:24:08 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2018-04-06 17:24:08 +0000 |
commit | a9ca709011d0621afa54fee11de39502db4b261b (patch) | |
tree | 80ebb921be9e1373c86f38640e16fb3d42d51fcc /llvm/test | |
parent | e0c2c49a15fb9e1f5a424c9269ab820038c480eb (diff) | |
download | bcm5719-llvm-a9ca709011d0621afa54fee11de39502db4b261b.tar.gz bcm5719-llvm-a9ca709011d0621afa54fee11de39502db4b261b.zip |
[InstCombine] limit nsz: -(X - Y) --> Y - X to hasOneUse()
As noted in the post-commit discussion for r329350, we shouldn't
generally assume that fsub is the same cost as fneg.
llvm-svn: 329429
Diffstat (limited to 'llvm/test')
-rw-r--r-- | llvm/test/Transforms/InstCombine/fsub.ll | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/test/Transforms/InstCombine/fsub.ll b/llvm/test/Transforms/InstCombine/fsub.ll index a209dee88fd..d3b1fe3d782 100644 --- a/llvm/test/Transforms/InstCombine/fsub.ll +++ b/llvm/test/Transforms/InstCombine/fsub.ll @@ -19,20 +19,24 @@ define float @test1(float %x, float %y) { define float @neg_sub_nsz(float %x, float %y) { ; CHECK-LABEL: @neg_sub_nsz( -; CHECK-NEXT: [[T2:%.*]] = fsub nsz float [[Y:%.*]], [[X:%.*]] -; CHECK-NEXT: ret float [[T2]] +; CHECK-NEXT: [[TMP1:%.*]] = fsub nsz float [[Y:%.*]], [[X:%.*]] +; CHECK-NEXT: ret float [[TMP1]] ; %t1 = fsub float %x, %y %t2 = fsub nsz float -0.0, %t1 ret float %t2 } +; If the subtract has another use, we don't do the transform (even though it +; doesn't increase the IR instruction count) because we assume that fneg is +; easier to analyze and generally cheaper than generic fsub. + declare void @use(float) define float @neg_sub_nsz_extra_use(float %x, float %y) { ; CHECK-LABEL: @neg_sub_nsz_extra_use( ; CHECK-NEXT: [[T1:%.*]] = fsub float [[X:%.*]], [[Y:%.*]] -; CHECK-NEXT: [[T2:%.*]] = fsub nsz float [[Y]], [[X]] +; CHECK-NEXT: [[T2:%.*]] = fsub nsz float -0.000000e+00, [[T1]] ; CHECK-NEXT: call void @use(float [[T1]]) ; CHECK-NEXT: ret float [[T2]] ; |