2015-11-24 05:33:58 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
2015-10-04 02:17:43 +08:00
|
|
|
; RUN: llc -mtriple=x86_64-unknown-unknown < %s | FileCheck %s
|
|
|
|
|
|
|
|
define float @fadd_zero_f32(float %x) #0 {
|
|
|
|
; CHECK-LABEL: fadd_zero_f32:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0:
|
2015-10-04 02:17:43 +08:00
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%y = fadd float %x, 0.0
|
|
|
|
ret float %y
|
|
|
|
}
|
|
|
|
|
|
|
|
define <4 x float> @fadd_zero_4f32(<4 x float> %x) #0 {
|
|
|
|
; CHECK-LABEL: fadd_zero_4f32:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0:
|
2015-10-04 02:17:43 +08:00
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%y = fadd <4 x float> %x, zeroinitializer
|
|
|
|
ret <4 x float> %y
|
|
|
|
}
|
|
|
|
|
2018-10-08 00:27:50 +08:00
|
|
|
define <4 x float> @fadd_zero_4f32_undef(<4 x float> %x) {
|
|
|
|
; CHECK-LABEL: fadd_zero_4f32_undef:
|
|
|
|
; CHECK: # %bb.0:
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%y = fadd nsz <4 x float> %x, <float 0.0, float undef, float 0.0, float undef>
|
|
|
|
ret <4 x float> %y
|
|
|
|
}
|
|
|
|
|
2015-10-04 06:06:06 +08:00
|
|
|
; CHECK: float 3
|
2015-10-04 02:17:43 +08:00
|
|
|
define float @fadd_2const_f32(float %x) #0 {
|
|
|
|
; CHECK-LABEL: fadd_2const_f32:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0:
|
2015-10-04 02:17:43 +08:00
|
|
|
; CHECK-NEXT: addss {{.*}}(%rip), %xmm0
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%y = fadd float %x, 1.0
|
|
|
|
%z = fadd float %y, 2.0
|
|
|
|
ret float %z
|
|
|
|
}
|
|
|
|
|
2015-12-08 10:37:48 +08:00
|
|
|
; CHECK: float 5
|
|
|
|
; CHECK: float 5
|
|
|
|
; CHECK: float 5
|
|
|
|
; CHECK: float 5
|
2015-10-04 02:17:43 +08:00
|
|
|
define <4 x float> @fadd_2const_4f32(<4 x float> %x) #0 {
|
|
|
|
; CHECK-LABEL: fadd_2const_4f32:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0:
|
2015-10-04 02:17:43 +08:00
|
|
|
; CHECK-NEXT: addps {{.*}}(%rip), %xmm0
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%y = fadd <4 x float> %x, <float 1.0, float 2.0, float 3.0, float 4.0>
|
|
|
|
%z = fadd <4 x float> %y, <float 4.0, float 3.0, float 2.0, float 1.0>
|
|
|
|
ret <4 x float> %z
|
|
|
|
}
|
|
|
|
|
2015-10-04 06:06:06 +08:00
|
|
|
; CHECK: float 3
|
2015-10-04 02:17:43 +08:00
|
|
|
define float @fadd_x_fmul_x_c_f32(float %x) #0 {
|
|
|
|
; CHECK-LABEL: fadd_x_fmul_x_c_f32:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0:
|
2015-10-04 02:17:43 +08:00
|
|
|
; CHECK-NEXT: mulss {{.*}}(%rip), %xmm0
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%y = fmul float %x, 2.0
|
|
|
|
%z = fadd float %x, %y
|
|
|
|
ret float %z
|
|
|
|
}
|
|
|
|
|
2015-12-08 10:37:48 +08:00
|
|
|
; CHECK: float 2
|
|
|
|
; CHECK: float 3
|
|
|
|
; CHECK: float 4
|
|
|
|
; CHECK: float 5
|
2015-10-04 02:17:43 +08:00
|
|
|
define <4 x float> @fadd_x_fmul_x_c_4f32(<4 x float> %x) #0 {
|
|
|
|
; CHECK-LABEL: fadd_x_fmul_x_c_4f32:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0:
|
2015-10-04 06:06:06 +08:00
|
|
|
; CHECK-NEXT: mulps {{.*}}(%rip), %xmm0
|
2015-10-04 02:17:43 +08:00
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%y = fmul <4 x float> %x, <float 1.0, float 2.0, float 3.0, float 4.0>
|
|
|
|
%z = fadd <4 x float> %x, %y
|
|
|
|
ret <4 x float> %z
|
|
|
|
}
|
|
|
|
|
2015-10-04 06:06:06 +08:00
|
|
|
; CHECK: float 3
|
2015-10-04 02:17:43 +08:00
|
|
|
define float @fadd_fmul_x_c_x_f32(float %x) #0 {
|
|
|
|
; CHECK-LABEL: fadd_fmul_x_c_x_f32:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0:
|
2015-10-04 02:17:43 +08:00
|
|
|
; CHECK-NEXT: mulss {{.*}}(%rip), %xmm0
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%y = fmul float %x, 2.0
|
|
|
|
%z = fadd float %y, %x
|
|
|
|
ret float %z
|
|
|
|
}
|
|
|
|
|
2015-12-08 10:37:48 +08:00
|
|
|
; CHECK: float 2
|
|
|
|
; CHECK: float 3
|
|
|
|
; CHECK: float 4
|
|
|
|
; CHECK: float 5
|
2015-10-04 02:17:43 +08:00
|
|
|
define <4 x float> @fadd_fmul_x_c_x_4f32(<4 x float> %x) #0 {
|
|
|
|
; CHECK-LABEL: fadd_fmul_x_c_x_4f32:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0:
|
2015-10-04 06:06:06 +08:00
|
|
|
; CHECK-NEXT: mulps {{.*}}(%rip), %xmm0
|
2015-10-04 02:17:43 +08:00
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%y = fmul <4 x float> %x, <float 1.0, float 2.0, float 3.0, float 4.0>
|
|
|
|
%z = fadd <4 x float> %y, %x
|
|
|
|
ret <4 x float> %z
|
|
|
|
}
|
|
|
|
|
2015-10-04 06:06:06 +08:00
|
|
|
; CHECK: float 4
|
2015-10-04 02:17:43 +08:00
|
|
|
define float @fadd_fadd_x_x_fmul_x_c_f32(float %x) #0 {
|
|
|
|
; CHECK-LABEL: fadd_fadd_x_x_fmul_x_c_f32:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0:
|
2015-10-04 02:17:43 +08:00
|
|
|
; CHECK-NEXT: mulss {{.*}}(%rip), %xmm0
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%y = fadd float %x, %x
|
|
|
|
%z = fmul float %x, 2.0
|
|
|
|
%w = fadd float %y, %z
|
|
|
|
ret float %w
|
|
|
|
}
|
|
|
|
|
2015-12-08 10:37:48 +08:00
|
|
|
; CHECK: float 3
|
|
|
|
; CHECK: float 4
|
|
|
|
; CHECK: float 5
|
|
|
|
; CHECK: float 6
|
2015-10-04 02:17:43 +08:00
|
|
|
define <4 x float> @fadd_fadd_x_x_fmul_x_c_4f32(<4 x float> %x) #0 {
|
|
|
|
; CHECK-LABEL: fadd_fadd_x_x_fmul_x_c_4f32:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0:
|
2015-10-04 06:06:06 +08:00
|
|
|
; CHECK-NEXT: mulps {{.*}}(%rip), %xmm0
|
2015-10-04 02:17:43 +08:00
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%y = fadd <4 x float> %x, %x
|
|
|
|
%z = fmul <4 x float> %x, <float 1.0, float 2.0, float 3.0, float 4.0>
|
|
|
|
%w = fadd <4 x float> %y, %z
|
|
|
|
ret <4 x float> %w
|
|
|
|
}
|
|
|
|
|
2015-10-04 06:06:06 +08:00
|
|
|
; CHECK: float 4
|
2015-10-04 02:17:43 +08:00
|
|
|
define float @fadd_fmul_x_c_fadd_x_x_f32(float %x) #0 {
|
|
|
|
; CHECK-LABEL: fadd_fmul_x_c_fadd_x_x_f32:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0:
|
2015-10-04 02:17:43 +08:00
|
|
|
; CHECK-NEXT: mulss {{.*}}(%rip), %xmm0
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%y = fadd float %x, %x
|
|
|
|
%z = fmul float %x, 2.0
|
|
|
|
%w = fadd float %z, %y
|
|
|
|
ret float %w
|
|
|
|
}
|
|
|
|
|
2015-12-08 10:37:48 +08:00
|
|
|
; CHECK: float 3
|
|
|
|
; CHECK: float 4
|
|
|
|
; CHECK: float 5
|
|
|
|
; CHECK: float 6
|
2015-10-04 02:17:43 +08:00
|
|
|
define <4 x float> @fadd_fmul_x_c_fadd_x_x_4f32(<4 x float> %x) #0 {
|
|
|
|
; CHECK-LABEL: fadd_fmul_x_c_fadd_x_x_4f32:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0:
|
2015-10-04 06:06:06 +08:00
|
|
|
; CHECK-NEXT: mulps {{.*}}(%rip), %xmm0
|
2015-10-04 02:17:43 +08:00
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%y = fadd <4 x float> %x, %x
|
|
|
|
%z = fmul <4 x float> %x, <float 1.0, float 2.0, float 3.0, float 4.0>
|
|
|
|
%w = fadd <4 x float> %z, %y
|
|
|
|
ret <4 x float> %w
|
|
|
|
}
|
|
|
|
|
2015-10-04 06:06:06 +08:00
|
|
|
; CHECK: float 3
|
2015-10-04 02:17:43 +08:00
|
|
|
define float @fadd_x_fadd_x_x_f32(float %x) #0 {
|
|
|
|
; CHECK-LABEL: fadd_x_fadd_x_x_f32:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0:
|
2015-10-04 02:17:43 +08:00
|
|
|
; CHECK-NEXT: mulss {{.*}}(%rip), %xmm0
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%y = fadd float %x, %x
|
|
|
|
%z = fadd float %x, %y
|
|
|
|
ret float %z
|
|
|
|
}
|
|
|
|
|
2015-12-08 10:37:48 +08:00
|
|
|
; CHECK: float 3
|
|
|
|
; CHECK: float 3
|
|
|
|
; CHECK: float 3
|
|
|
|
; CHECK: float 3
|
2015-10-04 02:17:43 +08:00
|
|
|
define <4 x float> @fadd_x_fadd_x_x_4f32(<4 x float> %x) #0 {
|
|
|
|
; CHECK-LABEL: fadd_x_fadd_x_x_4f32:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0:
|
2015-10-04 02:17:43 +08:00
|
|
|
; CHECK-NEXT: mulps {{.*}}(%rip), %xmm0
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%y = fadd <4 x float> %x, %x
|
|
|
|
%z = fadd <4 x float> %x, %y
|
|
|
|
ret <4 x float> %z
|
|
|
|
}
|
|
|
|
|
2015-10-04 06:06:06 +08:00
|
|
|
; CHECK: float 3
|
2015-10-04 02:17:43 +08:00
|
|
|
define float @fadd_fadd_x_x_x_f32(float %x) #0 {
|
|
|
|
; CHECK-LABEL: fadd_fadd_x_x_x_f32:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0:
|
2015-10-04 02:17:43 +08:00
|
|
|
; CHECK-NEXT: mulss {{.*}}(%rip), %xmm0
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%y = fadd float %x, %x
|
|
|
|
%z = fadd float %y, %x
|
|
|
|
ret float %z
|
|
|
|
}
|
|
|
|
|
2015-12-08 10:37:48 +08:00
|
|
|
; CHECK: float 3
|
|
|
|
; CHECK: float 3
|
|
|
|
; CHECK: float 3
|
|
|
|
; CHECK: float 3
|
2015-10-04 02:17:43 +08:00
|
|
|
define <4 x float> @fadd_fadd_x_x_x_4f32(<4 x float> %x) #0 {
|
|
|
|
; CHECK-LABEL: fadd_fadd_x_x_x_4f32:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0:
|
2015-10-04 02:17:43 +08:00
|
|
|
; CHECK-NEXT: mulps {{.*}}(%rip), %xmm0
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%y = fadd <4 x float> %x, %x
|
|
|
|
%z = fadd <4 x float> %y, %x
|
|
|
|
ret <4 x float> %z
|
|
|
|
}
|
|
|
|
|
2015-10-04 06:06:06 +08:00
|
|
|
; CHECK: float 4
|
2015-10-04 02:17:43 +08:00
|
|
|
define float @fadd_fadd_x_x_fadd_x_x_f32(float %x) #0 {
|
|
|
|
; CHECK-LABEL: fadd_fadd_x_x_fadd_x_x_f32:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0:
|
2015-10-04 02:17:43 +08:00
|
|
|
; CHECK-NEXT: mulss {{.*}}(%rip), %xmm0
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%y = fadd float %x, %x
|
|
|
|
%z = fadd float %y, %y
|
|
|
|
ret float %z
|
|
|
|
}
|
|
|
|
|
2015-12-08 10:37:48 +08:00
|
|
|
; CHECK: float 4
|
|
|
|
; CHECK: float 4
|
|
|
|
; CHECK: float 4
|
|
|
|
; CHECK: float 4
|
2015-10-04 02:17:43 +08:00
|
|
|
define <4 x float> @fadd_fadd_x_x_fadd_x_x_4f32(<4 x float> %x) #0 {
|
|
|
|
; CHECK-LABEL: fadd_fadd_x_x_fadd_x_x_4f32:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0:
|
2015-10-04 02:17:43 +08:00
|
|
|
; CHECK-NEXT: mulps {{.*}}(%rip), %xmm0
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%y = fadd <4 x float> %x, %x
|
|
|
|
%z = fadd <4 x float> %y, %y
|
|
|
|
ret <4 x float> %z
|
|
|
|
}
|
|
|
|
|
2018-06-13 23:01:07 +08:00
|
|
|
; ((x + 42.0) + 17.0) + (x + 42.0) --> (x + 59.0) + (x + 17.0)
|
2018-06-13 23:22:48 +08:00
|
|
|
; It's still 3 adds, but the first 2 are independent.
|
2018-06-13 23:01:07 +08:00
|
|
|
; More reassocation could get this to 2 adds or 1 FMA (that's done in IR, but not in the DAG).
|
|
|
|
|
|
|
|
define float @fadd_const_multiuse_attr(float %x) #0 {
|
|
|
|
; CHECK-LABEL: fadd_const_multiuse_attr:
|
|
|
|
; CHECK: # %bb.0:
|
|
|
|
; CHECK-NEXT: movss {{.*#+}} xmm1 = mem[0],zero,zero,zero
|
|
|
|
; CHECK-NEXT: addss %xmm0, %xmm1
|
2018-06-13 23:22:48 +08:00
|
|
|
; CHECK-NEXT: addss {{.*}}(%rip), %xmm0
|
2018-06-13 23:01:07 +08:00
|
|
|
; CHECK-NEXT: addss %xmm1, %xmm0
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%a1 = fadd float %x, 42.0
|
|
|
|
%a2 = fadd float %a1, 17.0
|
|
|
|
%a3 = fadd float %a1, %a2
|
|
|
|
ret float %a3
|
|
|
|
}
|
|
|
|
|
2019-08-09 22:52:31 +08:00
|
|
|
; PR32939 - https://bugs.llvm.org/show_bug.cgi?id=32939
|
|
|
|
|
|
|
|
define double @fmul2_negated(double %a, double %b, double %c) {
|
|
|
|
; CHECK-LABEL: fmul2_negated:
|
|
|
|
; CHECK: # %bb.0:
|
2019-08-10 05:37:32 +08:00
|
|
|
; CHECK-NEXT: addsd %xmm1, %xmm1
|
2019-08-09 22:52:31 +08:00
|
|
|
; CHECK-NEXT: mulsd %xmm2, %xmm1
|
2019-08-10 05:37:32 +08:00
|
|
|
; CHECK-NEXT: subsd %xmm1, %xmm0
|
2019-08-09 22:52:31 +08:00
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%mul = fmul double %b, 2.0
|
|
|
|
%mul1 = fmul double %mul, %c
|
|
|
|
%sub = fsub double %a, %mul1
|
|
|
|
ret double %sub
|
|
|
|
}
|
|
|
|
|
|
|
|
define <2 x double> @fmul2_negated_vec(<2 x double> %a, <2 x double> %b, <2 x double> %c) {
|
|
|
|
; CHECK-LABEL: fmul2_negated_vec:
|
|
|
|
; CHECK: # %bb.0:
|
2019-08-10 05:37:32 +08:00
|
|
|
; CHECK-NEXT: addpd %xmm1, %xmm1
|
2019-08-09 22:52:31 +08:00
|
|
|
; CHECK-NEXT: mulpd %xmm2, %xmm1
|
2019-08-10 05:37:32 +08:00
|
|
|
; CHECK-NEXT: subpd %xmm1, %xmm0
|
2019-08-09 22:52:31 +08:00
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%mul = fmul <2 x double> %b, <double 2.0, double 2.0>
|
|
|
|
%mul1 = fmul <2 x double> %mul, %c
|
|
|
|
%sub = fsub <2 x double> %a, %mul1
|
|
|
|
ret <2 x double> %sub
|
|
|
|
}
|
|
|
|
|
2017-03-09 09:36:39 +08:00
|
|
|
attributes #0 = { "less-precise-fpmad"="true" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "unsafe-fp-math"="true" "no-signed-zeros-fp-math"="true" }
|