summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/InstCombine/fsub.ll
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/test/Transforms/InstCombine/fsub.ll')
-rw-r--r--llvm/test/Transforms/InstCombine/fsub.ll13
1 files changed, 13 insertions, 0 deletions
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) {
OpenPOWER on IntegriCloud