1 ; RUN: llc -mtriple=x86_64-unknown-unknown -march=x86-64 < %s | FileCheck %s
3 ; CHECK-LABEL: fmul2_f32:
4 ; CHECK: addss %xmm0, %xmm0
5 define float @fmul2_f32(float %x) {
6 %y = fmul float %x, 2.0
10 ; fmul 2.0, x -> fadd x, x for vectors.
12 ; CHECK-LABEL: fmul2_v4f32:
13 ; CHECK: addps %xmm0, %xmm0
15 define <4 x float> @fmul2_v4f32(<4 x float> %x) {
16 %y = fmul <4 x float> %x, <float 2.0, float 2.0, float 2.0, float 2.0>
20 ; CHECK-LABEL: constant_fold_fmul_v4f32:
23 define <4 x float> @constant_fold_fmul_v4f32(<4 x float> %x) {
24 %y = fmul <4 x float> <float 4.0, float 4.0, float 4.0, float 4.0>, <float 2.0, float 2.0, float 2.0, float 2.0>
28 ; CHECK-LABEL: fmul0_v4f32:
29 ; CHECK: xorps %xmm0, %xmm0
31 define <4 x float> @fmul0_v4f32(<4 x float> %x) #0 {
32 %y = fmul <4 x float> %x, <float 0.0, float 0.0, float 0.0, float 0.0>
36 ; CHECK-LABEL: fmul_c2_c4_v4f32:
41 define <4 x float> @fmul_c2_c4_v4f32(<4 x float> %x) #0 {
42 %y = fmul <4 x float> %x, <float 2.0, float 2.0, float 2.0, float 2.0>
43 %z = fmul <4 x float> %y, <float 4.0, float 4.0, float 4.0, float 4.0>
47 ; CHECK-LABEL: fmul_c3_c4_v4f32:
52 define <4 x float> @fmul_c3_c4_v4f32(<4 x float> %x) #0 {
53 %y = fmul <4 x float> %x, <float 3.0, float 3.0, float 3.0, float 3.0>
54 %z = fmul <4 x float> %y, <float 4.0, float 4.0, float 4.0, float 4.0>
58 ; We should be able to pre-multiply the two constant vectors.
59 ; CHECK: float 5.000000e+00
60 ; CHECK: float 1.200000e+01
61 ; CHECK: float 2.100000e+01
62 ; CHECK: float 3.200000e+01
63 ; CHECK-LABEL: fmul_v4f32_two_consts_no_splat:
67 define <4 x float> @fmul_v4f32_two_consts_no_splat(<4 x float> %x) #0 {
68 %y = fmul <4 x float> %x, <float 1.0, float 2.0, float 3.0, float 4.0>
69 %z = fmul <4 x float> %y, <float 5.0, float 6.0, float 7.0, float 8.0>
73 ; Same as above, but reverse operands to make sure non-canonical form is also handled.
74 ; CHECK: float 5.000000e+00
75 ; CHECK: float 1.200000e+01
76 ; CHECK: float 2.100000e+01
77 ; CHECK: float 3.200000e+01
78 ; CHECK-LABEL: fmul_v4f32_two_consts_no_splat_non_canonical:
82 define <4 x float> @fmul_v4f32_two_consts_no_splat_non_canonical(<4 x float> %x) #0 {
83 %y = fmul <4 x float> <float 1.0, float 2.0, float 3.0, float 4.0>, %x
84 %z = fmul <4 x float> <float 5.0, float 6.0, float 7.0, float 8.0>, %y
88 ; More than one use of a constant multiply should not inhibit the optimization.
89 ; Instead of a chain of 2 dependent mults, this test will have 2 independent mults.
90 ; CHECK: float 5.000000e+00
91 ; CHECK: float 1.200000e+01
92 ; CHECK: float 2.100000e+01
93 ; CHECK: float 3.200000e+01
94 ; CHECK-LABEL: fmul_v4f32_two_consts_no_splat_multiple_use:
99 define <4 x float> @fmul_v4f32_two_consts_no_splat_multiple_use(<4 x float> %x) #0 {
100 %y = fmul <4 x float> %x, <float 1.0, float 2.0, float 3.0, float 4.0>
101 %z = fmul <4 x float> %y, <float 5.0, float 6.0, float 7.0, float 8.0>
102 %a = fadd <4 x float> %y, %z
106 ; CHECK-LABEL: fmul_c2_c4_f32:
111 define float @fmul_c2_c4_f32(float %x) #0 {
112 %y = fmul float %x, 2.0
113 %z = fmul float %y, 4.0
117 ; CHECK-LABEL: fmul_c3_c4_f32:
122 define float @fmul_c3_c4_f32(float %x) #0 {
123 %y = fmul float %x, 3.0
124 %z = fmul float %y, 4.0
128 ; CHECK-LABEL: fmul_fneg_fneg_f32:
129 ; CHECK: mulss %xmm1, %xmm0
131 define float @fmul_fneg_fneg_f32(float %x, float %y) {
132 %x.neg = fsub float -0.0, %x
133 %y.neg = fsub float -0.0, %y
134 %mul = fmul float %x.neg, %y.neg
137 ; CHECK-LABEL: fmul_fneg_fneg_v4f32:
138 ; CHECK: mulps {{%xmm1|\(%rdx\)}}, %xmm0
140 define <4 x float> @fmul_fneg_fneg_v4f32(<4 x float> %x, <4 x float> %y) {
141 %x.neg = fsub <4 x float> <float -0.0, float -0.0, float -0.0, float -0.0>, %x
142 %y.neg = fsub <4 x float> <float -0.0, float -0.0, float -0.0, float -0.0>, %y
143 %mul = fmul <4 x float> %x.neg, %y.neg
147 attributes #0 = { "less-precise-fpmad"="true" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "unsafe-fp-math"="true" }