; CHECK-NEXT: vmulss %xmm1, %xmm0, %xmm0
; CHECK-NEXT: vaddss %xmm0, %xmm0, %xmm0
; CHECK-NEXT: retq
-
%mul1 = fmul fast float %a, %b
%nega = fsub fast float 0.0, %a
%mul2 = fmul fast float %nega, %b
ret float %abx2
}
+define <4 x float> @fmf_should_not_break_cse_vector(<4 x float> %a, <4 x float> %b) {
+; CHECK-LABEL: fmf_should_not_break_cse_vector:
+; CHECK: # %bb.0:
+; CHECK-NEXT: vmulps %xmm1, %xmm0, %xmm0
+; CHECK-NEXT: vaddps %xmm0, %xmm0, %xmm0
+; CHECK-NEXT: retq
+ %mul1 = fmul fast <4 x float> %a, %b
+ %nega = fsub fast <4 x float> <float 0.0, float 0.0, float 0.0, float 0.0>, %a
+ %mul2 = fmul fast <4 x float> %nega, %b
+ %abx2 = fsub fast <4 x float> %mul1, %mul2
+ ret <4 x float> %abx2
+}
ret float %div
}
+define <4 x float> @double_negative_vector(<4 x float> %x, <4 x float> %y) #0 {
+; CHECK-LABEL: double_negative_vector:
+; CHECK: # %bb.0:
+; CHECK-NEXT: divps %xmm1, %xmm0
+; CHECK-NEXT: retq
+ %neg1 = fsub <4 x float> <float -0.0, float -0.0, float -0.0, float -0.0>, %x
+ %neg2 = fsub <4 x float> <float -0.0, float -0.0, float -0.0, float -0.0>, %y
+ %div = fdiv <4 x float> %neg1, %neg2
+ ret <4 x float> %div
+}
+
attributes #0 = { "unsafe-fp-math"="false" }
ret float %r
}
+define <4 x float> @fsub_neg_y_vector(<4 x float> %x, <4 x float>%y) {
+; ANY-LABEL: fsub_neg_y_vector:
+; ANY: # %bb.0:
+; ANY-NEXT: mulps {{.*}}(%rip), %xmm0
+; ANY-NEXT: xorps {{.*}}(%rip), %xmm0
+; ANY-NEXT: retq
+ %mul = fmul <4 x float> %x, <float 5.0, float 5.0, float 5.0, float 5.0>
+ %add = fadd <4 x float> %mul, %y
+ %r = fsub nsz reassoc <4 x float> %y, %add
+ ret <4 x float> %r
+}
+
define float @fsub_neg_y_commute(float %x, float %y) {
; ANY-LABEL: fsub_neg_y_commute:
; ANY: # %bb.0:
%r = fsub nsz reassoc float %y, %add
ret float %r
}
+
+define <4 x float> @fsub_neg_y_commute_vector(<4 x float> %x, <4 x float> %y) {
+; ANY-LABEL: fsub_neg_y_commute_vector:
+; ANY: # %bb.0:
+; ANY-NEXT: mulps {{.*}}(%rip), %xmm0
+; ANY-NEXT: xorps {{.*}}(%rip), %xmm0
+; ANY-NEXT: retq
+ %mul = fmul <4 x float> %x, <float 5.0, float 5.0, float 5.0, float 5.0>
+ %add = fadd <4 x float> %y, %mul
+ %r = fsub nsz reassoc <4 x float> %y, %add
+ ret <4 x float> %r
+}
+
; Y - (X + Y) --> -X
define float @fsub_fadd_common_op_fneg(float %x, float %y) {
ret float %r
}
+define <4 x float> @fsub_negzero_vector(<4 x float> %x) {
+; STRICT-LABEL: fsub_negzero_vector:
+; STRICT: # %bb.0:
+; STRICT-NEXT: subps {{.*}}(%rip), %xmm0
+; STRICT-NEXT: retq
+;
+; UNSAFE-LABEL: fsub_negzero_vector:
+; UNSAFE: # %bb.0:
+; UNSAFE-NEXT: retq
+ %r = fsub <4 x float> %x, <float -0.0, float -0.0, float -0.0, float -0.0>
+ ret <4 x float> %r
+}
+
define float @fsub_zero_nsz_1(float %x) {
; ANY-LABEL: fsub_zero_nsz_1:
; ANY: # %bb.0: