[NFC] adding tests for Y - (X + Y) --> -X

llvm-svn: 339197
This commit is contained in:
Michael Berg 2018-08-07 22:52:57 +00:00
parent cc365c376a
commit 2e60ad2e58
2 changed files with 26 additions and 0 deletions

View File

@ -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:

View File

@ -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) {