blob: 659cecb59ebf7c1a1fd70c07cdc22268479ffb34 [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
Jan Veselyb535c902014-10-17 14:45:27 +00002; RUN: llc -march=r600 -mcpu=cypress -verify-machineinstrs < %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s
Niels Ole Salscheider6509ac62013-08-10 10:38:47 +00003
Matt Arsenaultc6f8fdb2014-06-26 01:28:05 +00004declare float @llvm.fma.f32(float, float, float) nounwind readnone
5declare <2 x float> @llvm.fma.v2f32(<2 x float>, <2 x float>, <2 x float>) nounwind readnone
6declare <4 x float> @llvm.fma.v4f32(<4 x float>, <4 x float>, <4 x float>) nounwind readnone
Niels Ole Salscheider6509ac62013-08-10 10:38:47 +00007
Matt Arsenault95e48662014-11-13 19:26:47 +00008declare i32 @llvm.r600.read.tidig.x() nounwind readnone
9
Tom Stellard79243d92014-10-01 17:15:17 +000010; FUNC-LABEL: {{^}}fma_f32:
Tom Stellard326d6ec2014-11-05 14:50:53 +000011; SI: v_fma_f32 {{v[0-9]+, v[0-9]+, v[0-9]+, v[0-9]+}}
Jan Veselyb535c902014-10-17 14:45:27 +000012
13; EG: MEM_RAT_{{.*}} STORE_{{.*}} [[RES:T[0-9]\.[XYZW]]], {{T[0-9]\.[XYZW]}},
14; EG: FMA {{\*? *}}[[RES]]
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000015define amdgpu_kernel void @fma_f32(float addrspace(1)* %out, float addrspace(1)* %in1,
Niels Ole Salscheider6509ac62013-08-10 10:38:47 +000016 float addrspace(1)* %in2, float addrspace(1)* %in3) {
David Blaikiea79ac142015-02-27 21:17:42 +000017 %r0 = load float, float addrspace(1)* %in1
18 %r1 = load float, float addrspace(1)* %in2
19 %r2 = load float, float addrspace(1)* %in3
Matt Arsenault95e48662014-11-13 19:26:47 +000020 %r3 = tail call float @llvm.fma.f32(float %r0, float %r1, float %r2)
21 store float %r3, float addrspace(1)* %out
22 ret void
Niels Ole Salscheider6509ac62013-08-10 10:38:47 +000023}
24
Tom Stellard79243d92014-10-01 17:15:17 +000025; FUNC-LABEL: {{^}}fma_v2f32:
Tom Stellard326d6ec2014-11-05 14:50:53 +000026; SI: v_fma_f32
27; SI: v_fma_f32
Jan Veselyb535c902014-10-17 14:45:27 +000028
29; EG: MEM_RAT_{{.*}} STORE_{{.*}} [[RES:T[0-9]]].[[CHLO:[XYZW]]][[CHHI:[XYZW]]], {{T[0-9]\.[XYZW]}},
30; EG-DAG: FMA {{\*? *}}[[RES]].[[CHLO]]
31; EG-DAG: FMA {{\*? *}}[[RES]].[[CHHI]]
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000032define amdgpu_kernel void @fma_v2f32(<2 x float> addrspace(1)* %out, <2 x float> addrspace(1)* %in1,
Matt Arsenaultc6f8fdb2014-06-26 01:28:05 +000033 <2 x float> addrspace(1)* %in2, <2 x float> addrspace(1)* %in3) {
David Blaikiea79ac142015-02-27 21:17:42 +000034 %r0 = load <2 x float>, <2 x float> addrspace(1)* %in1
35 %r1 = load <2 x float>, <2 x float> addrspace(1)* %in2
36 %r2 = load <2 x float>, <2 x float> addrspace(1)* %in3
Matt Arsenault95e48662014-11-13 19:26:47 +000037 %r3 = tail call <2 x float> @llvm.fma.v2f32(<2 x float> %r0, <2 x float> %r1, <2 x float> %r2)
38 store <2 x float> %r3, <2 x float> addrspace(1)* %out
39 ret void
Matt Arsenaultc6f8fdb2014-06-26 01:28:05 +000040}
Niels Ole Salscheider6509ac62013-08-10 10:38:47 +000041
Tom Stellard79243d92014-10-01 17:15:17 +000042; FUNC-LABEL: {{^}}fma_v4f32:
Tom Stellard326d6ec2014-11-05 14:50:53 +000043; SI: v_fma_f32
44; SI: v_fma_f32
45; SI: v_fma_f32
46; SI: v_fma_f32
Jan Veselyb535c902014-10-17 14:45:27 +000047
48; EG: MEM_RAT_{{.*}} STORE_{{.*}} [[RES:T[0-9]]].{{[XYZW][XYZW][XYZW][XYZW]}}, {{T[0-9]\.[XYZW]}},
49; EG-DAG: FMA {{\*? *}}[[RES]].X
50; EG-DAG: FMA {{\*? *}}[[RES]].Y
51; EG-DAG: FMA {{\*? *}}[[RES]].Z
52; EG-DAG: FMA {{\*? *}}[[RES]].W
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000053define amdgpu_kernel void @fma_v4f32(<4 x float> addrspace(1)* %out, <4 x float> addrspace(1)* %in1,
Matt Arsenaultc6f8fdb2014-06-26 01:28:05 +000054 <4 x float> addrspace(1)* %in2, <4 x float> addrspace(1)* %in3) {
David Blaikiea79ac142015-02-27 21:17:42 +000055 %r0 = load <4 x float>, <4 x float> addrspace(1)* %in1
56 %r1 = load <4 x float>, <4 x float> addrspace(1)* %in2
57 %r2 = load <4 x float>, <4 x float> addrspace(1)* %in3
Matt Arsenault95e48662014-11-13 19:26:47 +000058 %r3 = tail call <4 x float> @llvm.fma.v4f32(<4 x float> %r0, <4 x float> %r1, <4 x float> %r2)
59 store <4 x float> %r3, <4 x float> addrspace(1)* %out
60 ret void
61}
62
63; FUNC-LABEL: @fma_commute_mul_inline_imm_f32
Matt Arsenault3d1c1de2016-04-14 21:58:24 +000064; SI: v_fma_f32 {{v[0-9]+}}, {{v[0-9]+}}, 2.0, {{v[0-9]+}}
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000065define amdgpu_kernel void @fma_commute_mul_inline_imm_f32(float addrspace(1)* noalias %out, float addrspace(1)* noalias %in.a, float addrspace(1)* noalias %in.b) nounwind {
Matt Arsenault95e48662014-11-13 19:26:47 +000066 %tid = tail call i32 @llvm.r600.read.tidig.x() nounwind readnone
David Blaikie79e6c742015-02-27 19:29:02 +000067 %in.a.gep = getelementptr float, float addrspace(1)* %in.a, i32 %tid
68 %in.b.gep = getelementptr float, float addrspace(1)* %in.b, i32 %tid
69 %out.gep = getelementptr float, float addrspace(1)* %out, i32 %tid
Matt Arsenault95e48662014-11-13 19:26:47 +000070
David Blaikiea79ac142015-02-27 21:17:42 +000071 %a = load float, float addrspace(1)* %in.a.gep, align 4
72 %b = load float, float addrspace(1)* %in.b.gep, align 4
Matt Arsenault95e48662014-11-13 19:26:47 +000073
74 %fma = call float @llvm.fma.f32(float %a, float 2.0, float %b)
75 store float %fma, float addrspace(1)* %out.gep, align 4
76 ret void
77}
78
79; FUNC-LABEL: @fma_commute_mul_s_f32
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000080define amdgpu_kernel void @fma_commute_mul_s_f32(float addrspace(1)* noalias %out, float addrspace(1)* noalias %in.a, float addrspace(1)* noalias %in.b, float %b) nounwind {
Matt Arsenault95e48662014-11-13 19:26:47 +000081 %tid = tail call i32 @llvm.r600.read.tidig.x() nounwind readnone
David Blaikie79e6c742015-02-27 19:29:02 +000082 %in.a.gep = getelementptr float, float addrspace(1)* %in.a, i32 %tid
83 %in.b.gep = getelementptr float, float addrspace(1)* %in.b, i32 %tid
84 %out.gep = getelementptr float, float addrspace(1)* %out, i32 %tid
Matt Arsenault95e48662014-11-13 19:26:47 +000085
David Blaikiea79ac142015-02-27 21:17:42 +000086 %a = load float, float addrspace(1)* %in.a.gep, align 4
87 %c = load float, float addrspace(1)* %in.b.gep, align 4
Matt Arsenault95e48662014-11-13 19:26:47 +000088
89 %fma = call float @llvm.fma.f32(float %a, float %b, float %c)
90 store float %fma, float addrspace(1)* %out.gep, align 4
91 ret void
Matt Arsenaultc6f8fdb2014-06-26 01:28:05 +000092}