diff --git a/llvm/test/CodeGen/X86/dag-fmf-cse.ll b/llvm/test/CodeGen/X86/dag-fmf-cse.ll index 021459eb4bde..609ccdc36739 100644 --- a/llvm/test/CodeGen/X86/dag-fmf-cse.ll +++ b/llvm/test/CodeGen/X86/dag-fmf-cse.ll @@ -12,7 +12,6 @@ define float @fmf_should_not_break_cse(float %a, float %b) { ; 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 @@ -20,3 +19,15 @@ define float @fmf_should_not_break_cse(float %a, float %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> , %a + %mul2 = fmul fast <4 x float> %nega, %b + %abx2 = fsub fast <4 x float> %mul1, %mul2 + ret <4 x float> %abx2 +} diff --git a/llvm/test/CodeGen/X86/fdiv.ll b/llvm/test/CodeGen/X86/fdiv.ll index f3956ecc0ea3..259cd91cca52 100644 --- a/llvm/test/CodeGen/X86/fdiv.ll +++ b/llvm/test/CodeGen/X86/fdiv.ll @@ -65,5 +65,16 @@ define float @double_negative(float %x, float %y) #0 { 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> , %x + %neg2 = fsub <4 x float> , %y + %div = fdiv <4 x float> %neg1, %neg2 + ret <4 x float> %div +} + attributes #0 = { "unsafe-fp-math"="false" } diff --git a/llvm/test/CodeGen/X86/fp-fold.ll b/llvm/test/CodeGen/X86/fp-fold.ll index 53fe3945c273..29a657a1f34d 100644 --- a/llvm/test/CodeGen/X86/fp-fold.ll +++ b/llvm/test/CodeGen/X86/fp-fold.ll @@ -99,6 +99,18 @@ define float @fsub_neg_y(float %x, float %y) { 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, + %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: @@ -109,6 +121,19 @@ define float @fsub_neg_y_commute(float %x, float %y) { %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, + %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) { @@ -172,6 +197,19 @@ define float @fsub_negzero(float %x) { 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, + ret <4 x float> %r +} + define float @fsub_zero_nsz_1(float %x) { ; ANY-LABEL: fsub_zero_nsz_1: ; ANY: # %bb.0: