blob: addc409c9eb15b23d4ef2a8f9cf32765c8c57d18 [file] [log] [blame]
Tom Stellard49f8bfd2015-01-06 18:00:21 +00001; RUN: llc -march=amdgcn -mcpu=SI -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
Marek Olsak75170772015-01-27 17:27:15 +00002; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
Matt Arsenault2b252ec2014-07-28 18:06:08 +00003; RUN: llc -march=r600 -mcpu=redwood < %s | FileCheck -check-prefix=R600 -check-prefix=FUNC %s
Tom Stellard75aadc22012-12-11 21:25:42 +00004
Matt Arsenault2b252ec2014-07-28 18:06:08 +00005
Tom Stellard79243d92014-10-01 17:15:17 +00006; FUNC-LABEL: {{^}}fmul_f32:
Matt Arsenault2b252ec2014-07-28 18:06:08 +00007; R600: MUL_IEEE {{\** *}}{{T[0-9]+\.[XYZW]}}, KC0[2].Z, KC0[2].W
8
Tom Stellard326d6ec2014-11-05 14:50:53 +00009; SI: v_mul_f32
Tom Stellarda92ff872013-08-16 23:51:24 +000010define void @fmul_f32(float addrspace(1)* %out, float %a, float %b) {
11entry:
12 %0 = fmul float %a, %b
13 store float %0, float addrspace(1)* %out
14 ret void
Tom Stellard75aadc22012-12-11 21:25:42 +000015}
16
17declare float @llvm.R600.load.input(i32) readnone
18
19declare void @llvm.AMDGPU.store.output(float, i32)
20
Tom Stellard79243d92014-10-01 17:15:17 +000021; FUNC-LABEL: {{^}}fmul_v2f32:
Matt Arsenault2b252ec2014-07-28 18:06:08 +000022; R600: MUL_IEEE {{\** *}}T{{[0-9]+\.[XYZW]}}
23; R600: MUL_IEEE {{\** *}}T{{[0-9]+\.[XYZW]}}
24
Tom Stellard326d6ec2014-11-05 14:50:53 +000025; SI: v_mul_f32
26; SI: v_mul_f32
Tom Stellard0344cdf2013-08-01 15:23:42 +000027define void @fmul_v2f32(<2 x float> addrspace(1)* %out, <2 x float> %a, <2 x float> %b) {
28entry:
29 %0 = fmul <2 x float> %a, %b
30 store <2 x float> %0, <2 x float> addrspace(1)* %out
31 ret void
32}
33
Tom Stellard79243d92014-10-01 17:15:17 +000034; FUNC-LABEL: {{^}}fmul_v4f32:
Matt Arsenault2b252ec2014-07-28 18:06:08 +000035; R600: MUL_IEEE {{\** *}}T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
36; R600: MUL_IEEE {{\** *}}T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
37; R600: MUL_IEEE {{\** *}}T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
38; R600: MUL_IEEE {{\** *}}T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
39
Tom Stellard326d6ec2014-11-05 14:50:53 +000040; SI: v_mul_f32
41; SI: v_mul_f32
42; SI: v_mul_f32
43; SI: v_mul_f32
Tom Stellard5a6b0d82013-04-19 02:10:53 +000044define void @fmul_v4f32(<4 x float> addrspace(1)* %out, <4 x float> addrspace(1)* %in) {
David Blaikie79e6c742015-02-27 19:29:02 +000045 %b_ptr = getelementptr <4 x float>, <4 x float> addrspace(1)* %in, i32 1
David Blaikiea79ac142015-02-27 21:17:42 +000046 %a = load <4 x float>, <4 x float> addrspace(1) * %in
47 %b = load <4 x float>, <4 x float> addrspace(1) * %b_ptr
Tom Stellard5a6b0d82013-04-19 02:10:53 +000048 %result = fmul <4 x float> %a, %b
49 store <4 x float> %result, <4 x float> addrspace(1)* %out
50 ret void
51}
Matt Arsenaultc1a71212014-09-02 19:02:53 +000052
Tom Stellard79243d92014-10-01 17:15:17 +000053; FUNC-LABEL: {{^}}test_mul_2_k:
Tom Stellard326d6ec2014-11-05 14:50:53 +000054; SI: v_mul_f32
55; SI-NOT: v_mul_f32
56; SI: s_endpgm
Matt Arsenaultc1a71212014-09-02 19:02:53 +000057define void @test_mul_2_k(float addrspace(1)* %out, float %x) #0 {
58 %y = fmul float %x, 2.0
59 %z = fmul float %y, 3.0
60 store float %z, float addrspace(1)* %out
61 ret void
62}
63
Tom Stellard79243d92014-10-01 17:15:17 +000064; FUNC-LABEL: {{^}}test_mul_2_k_inv:
Tom Stellard326d6ec2014-11-05 14:50:53 +000065; SI: v_mul_f32
66; SI-NOT: v_mul_f32
67; SI-NOT: v_mad_f32
68; SI: s_endpgm
Matt Arsenaultc1a71212014-09-02 19:02:53 +000069define void @test_mul_2_k_inv(float addrspace(1)* %out, float %x) #0 {
70 %y = fmul float %x, 3.0
71 %z = fmul float %y, 2.0
72 store float %z, float addrspace(1)* %out
73 ret void
74}
75
Fiona Glaser666e3522015-06-05 17:52:34 +000076; There should be three multiplies here; %a should be used twice (once
77; negated), not duplicated into mul x, 5.0 and mul x, -5.0.
78; FUNC-LABEL: {{^}}test_mul_twouse:
79; SI: v_mul_f32
80; SI: v_mul_f32
81; SI: v_mul_f32
82; SI-NOT: v_mul_f32
83define void @test_mul_twouse(float addrspace(1)* %out, float %x, float %y) #0 {
84 %a = fmul float %x, 5.0
85 %b = fsub float -0.0, %a
86 %c = fmul float %b, %y
87 %d = fmul float %c, %a
88 store float %d, float addrspace(1)* %out
89 ret void
90}
91
Matt Arsenaultc1a71212014-09-02 19:02:53 +000092attributes #0 = { "less-precise-fpmad"="true" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "unsafe-fp-math"="true" }