blob: 83f231a556821772ab666bc7f9b6073e6005a1fc [file] [log] [blame]
Stanislav Mekhanoshin692560d2019-05-01 16:32:58 +00001; RUN: llc < %s -march=amdgcn -mcpu=tonga -verify-machineinstrs | FileCheck -check-prefixes=GCN,UNPACKED,GFX89 %s
Rodrigo Dominguezf71f5f32020-04-03 17:37:51 -04002; RUN: llc < %s -march=amdgcn -mcpu=gfx810 -verify-machineinstrs | FileCheck -check-prefixes=GCN,GFX81,GFX89 %s
Mircea Trofinb4706302021-01-05 20:23:39 -08003; RUN: llc < %s -march=amdgcn -mcpu=gfx900 -verify-machineinstrs | FileCheck -check-prefixes=GCN,PACKED,GFX89 %s
Stanislav Mekhanoshin692560d2019-05-01 16:32:58 +00004; RUN: llc < %s -march=amdgcn -mcpu=gfx1010 -verify-machineinstrs | FileCheck -check-prefixes=GCN,GFX10 %s
Nicolai Haehnle2f5a7382018-04-04 10:58:54 +00005
6; GCN-LABEL: {{^}}image_load_f16:
Stanislav Mekhanoshin692560d2019-05-01 16:32:58 +00007; GFX89: image_load v0, v[0:1], s[0:7] dmask:0x1 unorm d16{{$}}
8; GFX10: image_load v0, v[0:1], s[0:7] dmask:0x1 dim:SQ_RSRC_IMG_2D unorm d16{{$}}
Nicolai Haehnle2f5a7382018-04-04 10:58:54 +00009define amdgpu_ps half @image_load_f16(<8 x i32> inreg %rsrc, i32 %s, i32 %t) {
10main_body:
11 %tex = call half @llvm.amdgcn.image.load.2d.f16.i32(i32 1, i32 %s, i32 %t, <8 x i32> %rsrc, i32 0, i32 0)
12 ret half %tex
13}
14
15; GCN-LABEL: {{^}}image_load_v2f16:
16; UNPACKED: image_load v[0:1], v[0:1], s[0:7] dmask:0x3 unorm d16{{$}}
17; PACKED: image_load v0, v[0:1], s[0:7] dmask:0x3 unorm d16{{$}}
Rodrigo Dominguezf71f5f32020-04-03 17:37:51 -040018; GFX81: image_load v0, v[0:1], s[0:7] dmask:0x3 unorm d16{{$}}
Stanislav Mekhanoshin692560d2019-05-01 16:32:58 +000019; GFX10: image_load v0, v[0:1], s[0:7] dmask:0x3 dim:SQ_RSRC_IMG_2D unorm d16{{$}}
Nicolai Haehnle2f5a7382018-04-04 10:58:54 +000020define amdgpu_ps float @image_load_v2f16(<8 x i32> inreg %rsrc, i32 %s, i32 %t) {
21main_body:
22 %tex = call <2 x half> @llvm.amdgcn.image.load.2d.v2f16.i32(i32 3, i32 %s, i32 %t, <8 x i32> %rsrc, i32 0, i32 0)
23 %r = bitcast <2 x half> %tex to float
24 ret float %r
25}
26
Sebastian Neubauer833b3b02020-07-23 16:59:00 +020027; GCN-LABEL: {{^}}image_load_v3f16:
28; UNPACKED: image_load v[0:2], v[0:1], s[0:7] dmask:0x7 unorm d16{{$}}
29; PACKED: image_load v[0:1], v[0:1], s[0:7] dmask:0x7 unorm d16{{$}}
30; GFX10: image_load v[0:1], v[0:1], s[0:7] dmask:0x7 dim:SQ_RSRC_IMG_2D unorm d16{{$}}
31define amdgpu_ps <2 x float> @image_load_v3f16(<8 x i32> inreg %rsrc, i32 %s, i32 %t) {
32main_body:
33 %tex = call <3 x half> @llvm.amdgcn.image.load.2d.v3f16.i32(i32 7, i32 %s, i32 %t, <8 x i32> %rsrc, i32 0, i32 0)
34 %ext = shufflevector <3 x half> %tex, <3 x half> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
35 %r = bitcast <4 x half> %ext to <2 x float>
36 ret <2 x float> %r
37}
38
Nicolai Haehnle2f5a7382018-04-04 10:58:54 +000039; GCN-LABEL: {{^}}image_load_v4f16:
40; UNPACKED: image_load v[0:3], v[0:1], s[0:7] dmask:0xf unorm d16{{$}}
41; PACKED: image_load v[0:1], v[0:1], s[0:7] dmask:0xf unorm d16{{$}}
Rodrigo Dominguezf71f5f32020-04-03 17:37:51 -040042; GFX81: image_load v[0:1], v[0:1], s[0:7] dmask:0xf unorm d16{{$}}
Stanislav Mekhanoshin692560d2019-05-01 16:32:58 +000043; GFX10: image_load v[0:1], v[0:1], s[0:7] dmask:0xf dim:SQ_RSRC_IMG_2D unorm d16{{$}}
Nicolai Haehnle2f5a7382018-04-04 10:58:54 +000044define amdgpu_ps <2 x float> @image_load_v4f16(<8 x i32> inreg %rsrc, i32 %s, i32 %t) {
45main_body:
46 %tex = call <4 x half> @llvm.amdgcn.image.load.2d.v4f16.i32(i32 15, i32 %s, i32 %t, <8 x i32> %rsrc, i32 0, i32 0)
47 %r = bitcast <4 x half> %tex to <2 x float>
48 ret <2 x float> %r
49}
50
51; GCN-LABEL: {{^}}image_load_mip_v4f16:
Sebastian Neubauer3bc7ffd2020-01-29 14:04:56 +010052; UNPACKED: image_load_mip v[0:3], v[0:2], s[0:7] dmask:0xf unorm d16{{$}}
53; PACKED: image_load_mip v[0:1], v[0:2], s[0:7] dmask:0xf unorm d16{{$}}
Rodrigo Dominguezf71f5f32020-04-03 17:37:51 -040054; GFX81: image_load_mip v[0:1], v[0:2], s[0:7] dmask:0xf unorm d16{{$}}
Stanislav Mekhanoshin692560d2019-05-01 16:32:58 +000055; GFX10: image_load_mip v[0:1], v[0:2], s[0:7] dmask:0xf dim:SQ_RSRC_IMG_2D unorm d16{{$}}
Nicolai Haehnle2f5a7382018-04-04 10:58:54 +000056define amdgpu_ps <2 x float> @image_load_mip_v4f16(<8 x i32> inreg %rsrc, i32 %s, i32 %t, i32 %mip) {
57main_body:
58 %tex = call <4 x half> @llvm.amdgcn.image.load.mip.2d.v4f16.i32(i32 15, i32 %s, i32 %t, i32 %mip, <8 x i32> %rsrc, i32 0, i32 0)
59 %r = bitcast <4 x half> %tex to <2 x float>
60 ret <2 x float> %r
61}
62
63; GCN-LABEL: {{^}}image_load_3d_v2f16:
Sebastian Neubauer3bc7ffd2020-01-29 14:04:56 +010064; UNPACKED: image_load v[0:1], v[0:2], s[0:7] dmask:0x3 unorm d16{{$}}
65; PACKED: image_load v0, v[0:2], s[0:7] dmask:0x3 unorm d16{{$}}
Rodrigo Dominguezf71f5f32020-04-03 17:37:51 -040066; GFX81: image_load v0, v[0:2], s[0:7] dmask:0x3 unorm d16{{$}}
Stanislav Mekhanoshin692560d2019-05-01 16:32:58 +000067; GFX10: image_load v0, v[0:2], s[0:7] dmask:0x3 dim:SQ_RSRC_IMG_3D unorm d16{{$}}
Nicolai Haehnle2f5a7382018-04-04 10:58:54 +000068define amdgpu_ps float @image_load_3d_v2f16(<8 x i32> inreg %rsrc, i32 %s, i32 %t, i32 %r) {
69main_body:
70 %tex = call <2 x half> @llvm.amdgcn.image.load.3d.v2f16.i32(i32 3, i32 %s, i32 %t, i32 %r, <8 x i32> %rsrc, i32 0, i32 0)
71 %x = bitcast <2 x half> %tex to float
72 ret float %x
73}
74
Sebastian Neubauer72ccec12020-11-05 15:09:56 +010075
76; GCN-LABEL: {{^}}image_load_3d_v3f16:
77; UNPACKED: image_load v[0:2], v[0:2], s[0:7] dmask:0x7 unorm d16
78; PACKED: image_load v[0:1], v[0:2], s[0:7] dmask:0x7 unorm d16
79; GFX81: image_load v[0:1], v[0:2], s[0:7] dmask:0x7 unorm d16
80; GFX10: image_load v[0:1], v[0:2], s[0:7] dmask:0x7 dim:SQ_RSRC_IMG_3D unorm d16{{$}}
Sebastian Neubauer833b3b02020-07-23 16:59:00 +020081define amdgpu_ps <2 x float> @image_load_3d_v3f16(<8 x i32> inreg %rsrc, i32 %s, i32 %t, i32 %r) {
82main_body:
83 %tex = call <3 x half> @llvm.amdgcn.image.load.3d.v3f16.i32(i32 7, i32 %s, i32 %t, i32 %r, <8 x i32> %rsrc, i32 0, i32 0)
84 %ext = shufflevector <3 x half> %tex, <3 x half> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
85 %res = bitcast <4 x half> %ext to <2 x float>
86 ret <2 x float> %res
87}
88
Nicolai Haehnle2f5a7382018-04-04 10:58:54 +000089; GCN-LABEL: {{^}}image_store_f16
Stanislav Mekhanoshin692560d2019-05-01 16:32:58 +000090; GFX89: image_store v2, v[0:1], s[0:7] dmask:0x1 unorm d16{{$}}
91; GFX10: image_store v2, v[0:1], s[0:7] dmask:0x1 dim:SQ_RSRC_IMG_2D unorm d16{{$}}
Nicolai Haehnle2f5a7382018-04-04 10:58:54 +000092define amdgpu_ps void @image_store_f16(<8 x i32> inreg %rsrc, i32 %s, i32 %t, half %data) {
93main_body:
94 call void @llvm.amdgcn.image.store.2d.f16.i32(half %data, i32 1, i32 %s, i32 %t, <8 x i32> %rsrc, i32 0, i32 0)
95 ret void
96}
97
98; GCN-LABEL: {{^}}image_store_v2f16
99; UNPACKED: v_lshrrev_b32_e32
100; UNPACKED: v_and_b32_e32
101; UNPACKED: image_store v[{{[0-9:]+}}], v[0:1], s[0:7] dmask:0x3 unorm d16{{$}}
102; PACKED: image_store v2, v[0:1], s[0:7] dmask:0x3 unorm d16{{$}}
Rodrigo Dominguezf71f5f32020-04-03 17:37:51 -0400103; GFX81: image_store v[2:3], v[0:1], s[0:7] dmask:0x3 unorm d16{{$}}
Stanislav Mekhanoshin692560d2019-05-01 16:32:58 +0000104; GFX10: image_store v2, v[0:1], s[0:7] dmask:0x3 dim:SQ_RSRC_IMG_2D unorm d16{{$}}
Nicolai Haehnle2f5a7382018-04-04 10:58:54 +0000105define amdgpu_ps void @image_store_v2f16(<8 x i32> inreg %rsrc, i32 %s, i32 %t, float %in) {
106main_body:
107 %data = bitcast float %in to <2 x half>
108 call void @llvm.amdgcn.image.store.2d.v2f16.i32(<2 x half> %data, i32 3, i32 %s, i32 %t, <8 x i32> %rsrc, i32 0, i32 0)
109 ret void
110}
111
Sebastian Neubauer72ccec12020-11-05 15:09:56 +0100112; GCN-LABEL: {{^}}image_store_v3f16:
113; UNPACKED: image_store v[2:4], v[0:1], s[0:7] dmask:0x7 unorm d16
114; PACKED: image_store v[2:3], v[0:1], s[0:7] dmask:0x7 unorm d16
115; GFX81: image_store v[2:4], v[0:1], s[0:7] dmask:0x7 unorm d16
116; GFX10: image_store v[2:3], v[0:1], s[0:7] dmask:0x7 dim:SQ_RSRC_IMG_2D unorm d16{{$}}
Sebastian Neubauer833b3b02020-07-23 16:59:00 +0200117define amdgpu_ps void @image_store_v3f16(<8 x i32> inreg %rsrc, i32 %s, i32 %t, <2 x float> %in) {
118main_body:
119 %r = bitcast <2 x float> %in to <4 x half>
120 %data = shufflevector <4 x half> %r, <4 x half> undef, <3 x i32> <i32 0, i32 1, i32 2>
121 call void @llvm.amdgcn.image.store.2d.v3f16.i32(<3 x half> %data, i32 7, i32 %s, i32 %t, <8 x i32> %rsrc, i32 0, i32 0)
122 ret void
123}
124
Nicolai Haehnle2f5a7382018-04-04 10:58:54 +0000125; GCN-LABEL: {{^}}image_store_v4f16
126; UNPACKED: v_lshrrev_b32_e32
127; UNPACKED: v_and_b32_e32
128; UNPACKED: v_lshrrev_b32_e32
129; UNPACKED: v_and_b32_e32
130; UNPACKED: image_store v[{{[0-9:]+}}], v[0:1], s[0:7] dmask:0xf unorm d16{{$}}
131; PACKED: image_store v[2:3], v[0:1], s[0:7] dmask:0xf unorm d16{{$}}
Rodrigo Dominguezf71f5f32020-04-03 17:37:51 -0400132; GFX81: image_store v[2:5], v[0:1], s[0:7] dmask:0xf unorm d16{{$}}
Stanislav Mekhanoshin692560d2019-05-01 16:32:58 +0000133; GFX10: image_store v[2:3], v[0:1], s[0:7] dmask:0xf dim:SQ_RSRC_IMG_2D unorm d16{{$}}
Nicolai Haehnle2f5a7382018-04-04 10:58:54 +0000134define amdgpu_ps void @image_store_v4f16(<8 x i32> inreg %rsrc, i32 %s, i32 %t, <2 x float> %in) {
135main_body:
136 %data = bitcast <2 x float> %in to <4 x half>
137 call void @llvm.amdgcn.image.store.2d.v4f16.i32(<4 x half> %data, i32 15, i32 %s, i32 %t, <8 x i32> %rsrc, i32 0, i32 0)
138 ret void
139}
140
141; GCN-LABEL: {{^}}image_store_mip_1d_v4f16
142; UNPACKED: v_lshrrev_b32_e32
143; UNPACKED: v_and_b32_e32
144; UNPACKED: v_lshrrev_b32_e32
145; UNPACKED: v_and_b32_e32
146; UNPACKED: image_store_mip v[{{[0-9:]+}}], v[0:1], s[0:7] dmask:0xf unorm d16{{$}}
147; PACKED: image_store_mip v[2:3], v[0:1], s[0:7] dmask:0xf unorm d16{{$}}
Rodrigo Dominguezf71f5f32020-04-03 17:37:51 -0400148; GFX81: image_store_mip v[2:5], v[0:1], s[0:7] dmask:0xf unorm d16{{$}}
Stanislav Mekhanoshin692560d2019-05-01 16:32:58 +0000149; GFX10: image_store_mip v[2:3], v[0:1], s[0:7] dmask:0xf dim:SQ_RSRC_IMG_1D unorm d16{{$}}
Nicolai Haehnle2f5a7382018-04-04 10:58:54 +0000150define amdgpu_ps void @image_store_mip_1d_v4f16(<8 x i32> inreg %rsrc, i32 %s, i32 %mip, <2 x float> %in) {
151main_body:
152 %data = bitcast <2 x float> %in to <4 x half>
153 call void @llvm.amdgcn.image.store.mip.1d.v4f16.i32(<4 x half> %data, i32 15, i32 %s, i32 %mip, <8 x i32> %rsrc, i32 0, i32 0)
154 ret void
155}
156
157declare half @llvm.amdgcn.image.load.2d.f16.i32(i32, i32, i32, <8 x i32>, i32, i32) #1
158declare <2 x half> @llvm.amdgcn.image.load.2d.v2f16.i32(i32, i32, i32, <8 x i32>, i32, i32) #1
Sebastian Neubauer833b3b02020-07-23 16:59:00 +0200159declare <3 x half> @llvm.amdgcn.image.load.2d.v3f16.i32(i32, i32, i32, <8 x i32>, i32, i32) #1
Nicolai Haehnle2f5a7382018-04-04 10:58:54 +0000160declare <4 x half> @llvm.amdgcn.image.load.2d.v4f16.i32(i32, i32, i32, <8 x i32>, i32, i32) #1
161declare <4 x half> @llvm.amdgcn.image.load.mip.2d.v4f16.i32(i32, i32, i32, i32, <8 x i32>, i32, i32) #1
162declare <2 x half> @llvm.amdgcn.image.load.3d.v2f16.i32(i32, i32, i32, i32, <8 x i32>, i32, i32) #1
Sebastian Neubauer833b3b02020-07-23 16:59:00 +0200163declare <3 x half> @llvm.amdgcn.image.load.3d.v3f16.i32(i32, i32, i32, i32, <8 x i32>, i32, i32) #1
Nicolai Haehnle2f5a7382018-04-04 10:58:54 +0000164
165declare void @llvm.amdgcn.image.store.2d.f16.i32(half, i32, i32, i32, <8 x i32>, i32, i32) #0
166declare void @llvm.amdgcn.image.store.2d.v2f16.i32(<2 x half>, i32, i32, i32, <8 x i32>, i32, i32) #0
Sebastian Neubauer833b3b02020-07-23 16:59:00 +0200167declare void @llvm.amdgcn.image.store.2d.v3f16.i32(<3 x half>, i32, i32, i32, <8 x i32>, i32, i32) #0
Nicolai Haehnle2f5a7382018-04-04 10:58:54 +0000168declare void @llvm.amdgcn.image.store.2d.v4f16.i32(<4 x half>, i32, i32, i32, <8 x i32>, i32, i32) #0
169declare void @llvm.amdgcn.image.store.mip.1d.v4f16.i32(<4 x half>, i32, i32, i32, <8 x i32>, i32, i32) #0
170declare void @llvm.amdgcn.image.store.3d.v2f16.i32(<2 x half>, i32, i32, i32, i32, <8 x i32>, i32, i32) #0
Sebastian Neubauer833b3b02020-07-23 16:59:00 +0200171declare void @llvm.amdgcn.image.store.3d.v3f16.i32(<3 x half>, i32, i32, i32, i32, <8 x i32>, i32, i32) #0
Nicolai Haehnle2f5a7382018-04-04 10:58:54 +0000172
173attributes #0 = { nounwind }
174attributes #1 = { nounwind readonly }
175attributes #2 = { nounwind readnone }