blob: a0122356720bc9415881e0233725244ccc608512 [file] [log] [blame]
Matt Arsenault6cc00422014-08-16 10:14:19 +00001; RUN: llc -march=x86-64 < %s | FileCheck %s
2
3; CHECK-LABEL: fmul2_f32:
4; CHECK: addss %xmm0, %xmm0
5define float @fmul2_f32(float %x) {
6 %y = fmul float %x, 2.0
7 ret float %y
8}
9
10; fmul 2.0, x -> fadd x, x for vectors.
11
12; CHECK-LABEL: fmul2_v4f32:
13; CHECK: addps %xmm0, %xmm0
14; CHECK-NEXT: retq
15define <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>
17 ret <4 x float> %y
18}
19
20; CHECK-LABEL: constant_fold_fmul_v4f32:
21; CHECK: movaps
22; CHECK-NEXT: ret
23define <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>
25 ret <4 x float> %y
26}
27
28; CHECK-LABEL: fmul0_v4f32:
29; CHECK: xorps %xmm0, %xmm0
30; CHECK-NEXT: retq
31define <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>
33 ret <4 x float> %y
34}
35
36; CHECK-LABEL: fmul_c2_c4_v4f32:
37; CHECK-NOT: addps
38; CHECK: mulps
39; CHECK-NOT: mulps
40; CHECK-NEXT: ret
41define <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>
44 ret <4 x float> %z
45}
46
47; CHECK-LABEL: fmul_c3_c4_v4f32:
48; CHECK-NOT: addps
49; CHECK: mulps
50; CHECK-NOT: mulps
51; CHECK-NEXT: ret
52define <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>
55 ret <4 x float> %z
56}
57
58; CHECK-LABEL: fmul_c2_c4_f32:
59; CHECK-NOT: addss
60; CHECK: mulss
61; CHECK-NOT: mulss
62; CHECK-NEXT: ret
63define float @fmul_c2_c4_f32(float %x) #0 {
64 %y = fmul float %x, 2.0
65 %z = fmul float %y, 4.0
66 ret float %z
67}
68
69; CHECK-LABEL: fmul_c3_c4_f32:
70; CHECK-NOT: addss
71; CHECK: mulss
72; CHECK-NOT: mulss
73; CHECK-NET: ret
74define float @fmul_c3_c4_f32(float %x) #0 {
75 %y = fmul float %x, 3.0
76 %z = fmul float %y, 4.0
77 ret float %z
78}
79
80; CHECK-LABEL: fmul_fneg_fneg_f32:
81; CHECK: mulss %xmm1, %xmm0
82; CHECK-NEXT: retq
83define float @fmul_fneg_fneg_f32(float %x, float %y) {
84 %x.neg = fsub float -0.0, %x
85 %y.neg = fsub float -0.0, %y
86 %mul = fmul float %x.neg, %y.neg
87 ret float %mul
88}
89; CHECK-LABEL: fmul_fneg_fneg_v4f32:
NAKAMURA Takumi067d4c72014-08-16 22:28:37 +000090; CHECK: mulps {{%xmm1|\(%rdx\)}}, %xmm0
Matt Arsenault6cc00422014-08-16 10:14:19 +000091; CHECK-NEXT: retq
92define <4 x float> @fmul_fneg_fneg_v4f32(<4 x float> %x, <4 x float> %y) {
93 %x.neg = fsub <4 x float> <float -0.0, float -0.0, float -0.0, float -0.0>, %x
94 %y.neg = fsub <4 x float> <float -0.0, float -0.0, float -0.0, float -0.0>, %y
95 %mul = fmul <4 x float> %x.neg, %y.neg
96 ret <4 x float> %mul
97}
98
99attributes #0 = { "less-precise-fpmad"="true" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "unsafe-fp-math"="true" }