forked from OSchip/llvm-project
[X86][SSE] Add vector tests to cover more isNegatibleForFree/GetNegatedExpression cases (PR42105)
Some already combine correctly, but vector constant analysis is weak. llvm-svn: 362633
This commit is contained in:
parent
84cfca0f2b
commit
036fa5346f
|
@ -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> <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
|
||||
}
|
||||
|
|
|
@ -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> <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" }
|
||||
|
||||
|
|
|
@ -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, <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:
|
||||
|
@ -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, <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) {
|
||||
|
@ -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, <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:
|
||||
|
|
Loading…
Reference in New Issue