diff options
-rw-r--r-- | llvm/test/Transforms/InstCombine/fsub.ll | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/llvm/test/Transforms/InstCombine/fsub.ll b/llvm/test/Transforms/InstCombine/fsub.ll index 3fbafc28bf4..184d24f5bad 100644 --- a/llvm/test/Transforms/InstCombine/fsub.ll +++ b/llvm/test/Transforms/InstCombine/fsub.ll @@ -14,11 +14,11 @@ define float @test1(float %x, float %y) { ret float %t2 } -; FIXME: Can't do anything with the test above because -0.0 - 0.0 = -0.0, but if we have nsz: +; 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( +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]] ; @@ -27,6 +27,32 @@ define float @neg_sub(float %x, float %y) { ret float %t2 } +; FIXME: With nsz: Z - (X - Y) --> Z + (Y - X) + +define float @sub_sub_nsz(float %x, float %y, float %z) { +; CHECK-LABEL: @sub_sub_nsz( +; CHECK-NEXT: [[T1:%.*]] = fsub float [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[T2:%.*]] = fsub nsz float [[Z:%.*]], [[T1]] +; CHECK-NEXT: ret float [[T2]] +; + %t1 = fsub float %x, %y + %t2 = fsub nsz float %z, %t1 + ret float %t2 +} + +; FIXME: Same as above: if 'Z' is not -0.0, swap fsub operands and convert to fadd. + +define float @sub_sub_known_not_negzero(float %x, float %y) { +; CHECK-LABEL: @sub_sub_known_not_negzero( +; CHECK-NEXT: [[T1:%.*]] = fsub float [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[T2:%.*]] = fsub float 4.200000e+01, [[T1]] +; CHECK-NEXT: ret float [[T2]] +; + %t1 = fsub float %x, %y + %t2 = fsub float 42.0, %t1 + ret float %t2 +} + ; <rdar://problem/7530098> define double @test2(double %x, double %y) { |