diff options
-rw-r--r-- | llvm/test/CodeGen/X86/fp-fold.ll | 13 | ||||
-rw-r--r-- | llvm/test/Transforms/InstCombine/fsub.ll | 13 |
2 files changed, 26 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/X86/fp-fold.ll b/llvm/test/CodeGen/X86/fp-fold.ll index b8e30a4ce42..d3d965b95b0 100644 --- a/llvm/test/CodeGen/X86/fp-fold.ll +++ b/llvm/test/CodeGen/X86/fp-fold.ll @@ -88,6 +88,19 @@ define float @fsub_neg_x_y(float %x, float %y) { ret float %r } +define float @fsub_neg_y(float %x, float %y) { +; UNSAFE-LABEL: fsub_neg_y: +; UNSAFE: # %bb.0: +; UNSAFE-NEXT: mulss {{.*}}(%rip), %xmm0 +; UNSAFE-NEXT: subss %xmm1, %xmm0 +; UNSAFE-NEXT: addss %xmm1, %xmm0 +; UNSAFE-NEXT: retq + %mul = fmul float %x, 5.000000e+00 + %add = fadd float %mul, %y + %r = fsub nsz reassoc float %y, %add + ret float %r +} + define float @fsub_negzero(float %x) { ; STRICT-LABEL: fsub_negzero: ; STRICT: # %bb.0: diff --git a/llvm/test/Transforms/InstCombine/fsub.ll b/llvm/test/Transforms/InstCombine/fsub.ll index 22295490cc6..b4567500df0 100644 --- a/llvm/test/Transforms/InstCombine/fsub.ll +++ b/llvm/test/Transforms/InstCombine/fsub.ll @@ -60,6 +60,19 @@ define float @sub_sub_nsz(float %x, float %y, float %z) { ret float %t2 } +; With nsz and reassoc: Y - (X + Y) --> -X +define float @sub_add_neg_x(float %x, float %y) { +; CHECK-LABEL: @sub_add_neg_x( +; CHECK-NEXT: [[TMP1:%.*]] = fmul float [[X:%.*]], 5.000000e+00 +; CHECK-NEXT: [[T2:%.*]] = fsub reassoc nsz float -0.000000e+00, [[TMP1]] +; CHECK-NEXT: ret float [[T2]] +; + %mul = fmul float %x, 5.000000e+00 + %add = fadd float %mul, %y + %r = fsub nsz reassoc float %y, %add + ret float %r +} + ; 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) { |