annotate llvm/test/CodeGen/AMDGPU/mad_uint24.ll @ 266:00f31e85ec16 default tip

Added tag current for changeset 31d058e83c98
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 14 Oct 2023 10:13:55 +0900
parents 1f2b6ac9f198
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 ; RUN: llc < %s -march=r600 -mcpu=redwood | FileCheck %s --check-prefix=EG --check-prefix=FUNC
anatofuz
parents:
diff changeset
2 ; RUN: llc < %s -march=r600 -mcpu=cayman | FileCheck %s --check-prefix=EG --check-prefix=FUNC
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
3 ; RUN: llc < %s -march=amdgcn -verify-machineinstrs | FileCheck %s --check-prefix=SI --check-prefix=FUNC --check-prefix=GCN
150
anatofuz
parents:
diff changeset
4 ; RUN: llc < %s -march=amdgcn -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs | FileCheck %s --check-prefix=VI --check-prefix=FUNC --check-prefix=GCN --check-prefix=GCN2
anatofuz
parents:
diff changeset
5 ; RUN: llc < %s -march=amdgcn -mcpu=fiji -mattr=-flat-for-global -verify-machineinstrs | FileCheck %s --check-prefix=VI --check-prefix=FUNC --check-prefix=GCN --check-prefix=GCN2
anatofuz
parents:
diff changeset
6
anatofuz
parents:
diff changeset
7 declare i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
anatofuz
parents:
diff changeset
8
anatofuz
parents:
diff changeset
9 ; FUNC-LABEL: {{^}}u32_mad24:
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
10 ; EG: MULLO_INT
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
11 ; SI: s_mul_i32
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
12 ; SI: s_add_i32
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
13 ; VI: s_mul_{{[iu]}}32
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
14 ; VI: s_add_{{[iu]}}32
150
anatofuz
parents:
diff changeset
15
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
16 define amdgpu_kernel void @u32_mad24(ptr addrspace(1) %out, i32 %a, i32 %b, i32 %c) {
150
anatofuz
parents:
diff changeset
17 entry:
anatofuz
parents:
diff changeset
18 %0 = shl i32 %a, 8
anatofuz
parents:
diff changeset
19 %a_24 = lshr i32 %0, 8
anatofuz
parents:
diff changeset
20 %1 = shl i32 %b, 8
anatofuz
parents:
diff changeset
21 %b_24 = lshr i32 %1, 8
anatofuz
parents:
diff changeset
22 %2 = mul i32 %a_24, %b_24
anatofuz
parents:
diff changeset
23 %3 = add i32 %2, %c
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
24 store i32 %3, ptr addrspace(1) %out
150
anatofuz
parents:
diff changeset
25 ret void
anatofuz
parents:
diff changeset
26 }
anatofuz
parents:
diff changeset
27
anatofuz
parents:
diff changeset
28 ; FUNC-LABEL: {{^}}i16_mad24:
anatofuz
parents:
diff changeset
29 ; The order of A and B does not matter.
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
30 ; EG: MULLO_INT {{[* ]*}}T{{[0-9]}}.[[MAD_CHAN:[XYZW]]]
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
31 ; EG: ADD_INT {{[* ]*}}T{{[0-9]}}.[[MAD_CHAN:[XYZW]]]
150
anatofuz
parents:
diff changeset
32 ; The result must be sign-extended
anatofuz
parents:
diff changeset
33 ; EG: BFE_INT {{[* ]*}}T{{[0-9]\.[XYZW]}}, PV.[[MAD_CHAN]], 0.0, literal.x
anatofuz
parents:
diff changeset
34 ; EG: 16
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
35 ; GCN: s_mul_i32 [[MUL:s[0-9]]], {{[s][0-9], [s][0-9]}}
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
36 ; GCN: s_add_i32 [[MAD:s[0-9]]], [[MUL]], s{{[0-9]}}
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
37 ; GCN: s_sext_i32_i16 [[EXT:s[0-9]]], [[MAD]]
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
38 ; GCN: v_mov_b32_e32 v0, [[EXT]]
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
39 define amdgpu_kernel void @i16_mad24(ptr addrspace(1) %out, i16 %a, i16 %b, i16 %c) {
150
anatofuz
parents:
diff changeset
40 entry:
anatofuz
parents:
diff changeset
41 %0 = mul i16 %a, %b
anatofuz
parents:
diff changeset
42 %1 = add i16 %0, %c
anatofuz
parents:
diff changeset
43 %2 = sext i16 %1 to i32
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
44 store i32 %2, ptr addrspace(1) %out
150
anatofuz
parents:
diff changeset
45 ret void
anatofuz
parents:
diff changeset
46 }
anatofuz
parents:
diff changeset
47
anatofuz
parents:
diff changeset
48 ; FIXME: Need to handle non-uniform case for function below (load without gep).
anatofuz
parents:
diff changeset
49 ; FUNC-LABEL: {{^}}i8_mad24:
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
50 ; EG: MULLO_INT {{[* ]*}}T{{[0-9]}}.[[MAD_CHAN:[XYZW]]]
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
51 ; EG: ADD_INT {{[* ]*}}T{{[0-9]}}.[[MAD_CHAN:[XYZW]]]
150
anatofuz
parents:
diff changeset
52 ; The result must be sign-extended
anatofuz
parents:
diff changeset
53 ; EG: BFE_INT {{[* ]*}}T{{[0-9]\.[XYZW]}}, PV.[[MAD_CHAN]], 0.0, literal.x
anatofuz
parents:
diff changeset
54 ; EG: 8
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
55 ; GCN: s_mul_i32 [[MUL:s[0-9]]], {{[s][0-9], [s][0-9]}}
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
56 ; GCN: s_add_i32 [[MAD:s[0-9]]], [[MUL]], s{{[0-9]}}
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
57 ; GCN: s_sext_i32_i8 [[EXT:s[0-9]]], [[MAD]]
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
58 ; GCN: v_mov_b32_e32 v0, [[EXT]]
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
59 define amdgpu_kernel void @i8_mad24(ptr addrspace(1) %out, i8 %a, i8 %b, i8 %c) {
150
anatofuz
parents:
diff changeset
60 entry:
anatofuz
parents:
diff changeset
61 %0 = mul i8 %a, %b
anatofuz
parents:
diff changeset
62 %1 = add i8 %0, %c
anatofuz
parents:
diff changeset
63 %2 = sext i8 %1 to i32
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
64 store i32 %2, ptr addrspace(1) %out
150
anatofuz
parents:
diff changeset
65 ret void
anatofuz
parents:
diff changeset
66 }
anatofuz
parents:
diff changeset
67
anatofuz
parents:
diff changeset
68 ; This tests for a bug where the mad_u24 pattern matcher would call
anatofuz
parents:
diff changeset
69 ; SimplifyDemandedBits on the first operand of the mul instruction
anatofuz
parents:
diff changeset
70 ; assuming that the pattern would be matched to a 24-bit mad. This
anatofuz
parents:
diff changeset
71 ; led to some instructions being incorrectly erased when the entire
anatofuz
parents:
diff changeset
72 ; 24-bit mad pattern wasn't being matched.
anatofuz
parents:
diff changeset
73
anatofuz
parents:
diff changeset
74 ; Check that the select instruction is not deleted.
anatofuz
parents:
diff changeset
75 ; FUNC-LABEL: {{^}}i24_i32_i32_mad:
anatofuz
parents:
diff changeset
76 ; EG: CNDE_INT
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
77 ; SI: s_cselect
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
78 ; GCN2: s_cselect
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
79 define amdgpu_kernel void @i24_i32_i32_mad(ptr addrspace(1) %out, i32 %a, i32 %b, i32 %c, i32 %d) {
150
anatofuz
parents:
diff changeset
80 entry:
anatofuz
parents:
diff changeset
81 %0 = ashr i32 %a, 8
anatofuz
parents:
diff changeset
82 %1 = icmp ne i32 %c, 0
anatofuz
parents:
diff changeset
83 %2 = select i1 %1, i32 %0, i32 34
anatofuz
parents:
diff changeset
84 %3 = mul i32 %2, %c
anatofuz
parents:
diff changeset
85 %4 = add i32 %3, %d
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
86 store i32 %4, ptr addrspace(1) %out
150
anatofuz
parents:
diff changeset
87 ret void
anatofuz
parents:
diff changeset
88 }
anatofuz
parents:
diff changeset
89
anatofuz
parents:
diff changeset
90 ; FUNC-LABEL: {{^}}extra_and:
anatofuz
parents:
diff changeset
91 ; SI-NOT: v_and
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
92 ; SI: s_mul_i32
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
93 ; SI: s_mul_i32
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
94 ; SI: s_add_i32
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
95 ; SI: s_add_i32
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
96 define amdgpu_kernel void @extra_and(ptr addrspace(1) %arg, i32 %arg2, i32 %arg3) {
150
anatofuz
parents:
diff changeset
97 bb:
anatofuz
parents:
diff changeset
98 br label %bb4
anatofuz
parents:
diff changeset
99
anatofuz
parents:
diff changeset
100 bb4: ; preds = %bb4, %bb
anatofuz
parents:
diff changeset
101 %tmp = phi i32 [ 0, %bb ], [ %tmp13, %bb4 ]
anatofuz
parents:
diff changeset
102 %tmp5 = phi i32 [ 0, %bb ], [ %tmp13, %bb4 ]
anatofuz
parents:
diff changeset
103 %tmp6 = phi i32 [ 0, %bb ], [ %tmp15, %bb4 ]
anatofuz
parents:
diff changeset
104 %tmp7 = phi i32 [ 0, %bb ], [ %tmp15, %bb4 ]
anatofuz
parents:
diff changeset
105 %tmp8 = and i32 %tmp7, 16777215
anatofuz
parents:
diff changeset
106 %tmp9 = and i32 %tmp6, 16777215
anatofuz
parents:
diff changeset
107 %tmp10 = and i32 %tmp5, 16777215
anatofuz
parents:
diff changeset
108 %tmp11 = and i32 %tmp, 16777215
anatofuz
parents:
diff changeset
109 %tmp12 = mul i32 %tmp8, %tmp11
anatofuz
parents:
diff changeset
110 %tmp13 = add i32 %arg2, %tmp12
anatofuz
parents:
diff changeset
111 %tmp14 = mul i32 %tmp9, %tmp11
anatofuz
parents:
diff changeset
112 %tmp15 = add i32 %arg3, %tmp14
anatofuz
parents:
diff changeset
113 %tmp16 = add nuw nsw i32 %tmp13, %tmp15
anatofuz
parents:
diff changeset
114 %tmp17 = icmp eq i32 %tmp16, 8
anatofuz
parents:
diff changeset
115 br i1 %tmp17, label %bb18, label %bb4
anatofuz
parents:
diff changeset
116
anatofuz
parents:
diff changeset
117 bb18: ; preds = %bb4
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
118 store i32 %tmp16, ptr addrspace(1) %arg
150
anatofuz
parents:
diff changeset
119 ret void
anatofuz
parents:
diff changeset
120 }
anatofuz
parents:
diff changeset
121
anatofuz
parents:
diff changeset
122 ; FUNC-LABEL: {{^}}dont_remove_shift
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
123 ; SI: s_lshr
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
124 ; SI: s_mul_i32
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
125 ; SI: s_mul_i32
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
126 ; SI: s_add_i32
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
127 ; SI: s_add_i32
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
128 define amdgpu_kernel void @dont_remove_shift(ptr addrspace(1) %arg, i32 %arg2, i32 %arg3) {
150
anatofuz
parents:
diff changeset
129 bb:
anatofuz
parents:
diff changeset
130 br label %bb4
anatofuz
parents:
diff changeset
131
anatofuz
parents:
diff changeset
132 bb4: ; preds = %bb4, %bb
anatofuz
parents:
diff changeset
133 %tmp = phi i32 [ 0, %bb ], [ %tmp13, %bb4 ]
anatofuz
parents:
diff changeset
134 %tmp5 = phi i32 [ 0, %bb ], [ %tmp13, %bb4 ]
anatofuz
parents:
diff changeset
135 %tmp6 = phi i32 [ 0, %bb ], [ %tmp15, %bb4 ]
anatofuz
parents:
diff changeset
136 %tmp7 = phi i32 [ 0, %bb ], [ %tmp15, %bb4 ]
anatofuz
parents:
diff changeset
137 %tmp8 = lshr i32 %tmp7, 8
anatofuz
parents:
diff changeset
138 %tmp9 = lshr i32 %tmp6, 8
anatofuz
parents:
diff changeset
139 %tmp10 = lshr i32 %tmp5, 8
anatofuz
parents:
diff changeset
140 %tmp11 = lshr i32 %tmp, 8
anatofuz
parents:
diff changeset
141 %tmp12 = mul i32 %tmp8, %tmp11
anatofuz
parents:
diff changeset
142 %tmp13 = add i32 %arg2, %tmp12
anatofuz
parents:
diff changeset
143 %tmp14 = mul i32 %tmp9, %tmp11
anatofuz
parents:
diff changeset
144 %tmp15 = add i32 %arg3, %tmp14
anatofuz
parents:
diff changeset
145 %tmp16 = add nuw nsw i32 %tmp13, %tmp15
anatofuz
parents:
diff changeset
146 %tmp17 = icmp eq i32 %tmp16, 8
anatofuz
parents:
diff changeset
147 br i1 %tmp17, label %bb18, label %bb4
anatofuz
parents:
diff changeset
148
anatofuz
parents:
diff changeset
149 bb18: ; preds = %bb4
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
150 store i32 %tmp16, ptr addrspace(1) %arg
150
anatofuz
parents:
diff changeset
151 ret void
anatofuz
parents:
diff changeset
152 }
anatofuz
parents:
diff changeset
153
anatofuz
parents:
diff changeset
154 ; FUNC-LABEL: {{^}}i8_mad_sat_16:
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
155 ; EG: MULLO_INT {{[* ]*}}T{{[0-9]}}.[[MAD_CHAN:[XYZW]]]
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
156 ; EG: ADD_INT {{[* ]*}}T{{[0-9]}}.[[MAD_CHAN:[XYZW]]]
150
anatofuz
parents:
diff changeset
157 ; The result must be sign-extended
anatofuz
parents:
diff changeset
158 ; EG: BFE_INT {{[* ]*}}T{{[0-9]\.[XYZW]}}, PV.[[MAD_CHAN]], 0.0, literal.x
anatofuz
parents:
diff changeset
159 ; EG: 8
anatofuz
parents:
diff changeset
160 ; SI: v_mad_u32_u24 [[MAD:v[0-9]]], {{[sv][0-9], [sv][0-9]}}
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
161 ; SI: v_bfe_i32 [[EXT:v[0-9]]], [[MAD]], 0, 16
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
162 ; SI: v_med3_i32 v{{[0-9]}}, [[EXT]],
150
anatofuz
parents:
diff changeset
163 ; VI: v_mad_u16 [[MAD:v[0-9]]], {{[sv][0-9], [sv][0-9]}}
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
164 ; VI: v_max_i16_e32 [[MAX:v[0-9]]], 0xff80, [[MAD]]
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
165 ; VI: v_min_i16_e32 {{v[0-9]}}, 0x7f, [[MAX]]
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
166 define amdgpu_kernel void @i8_mad_sat_16(ptr addrspace(1) %out, ptr addrspace(1) %in0, ptr addrspace(1) %in1, ptr addrspace(1) %in2, ptr addrspace(5) %idx) {
150
anatofuz
parents:
diff changeset
167 entry:
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
168 %retval.0.i = load i64, ptr addrspace(5) %idx
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
169 %arrayidx = getelementptr inbounds i8, ptr addrspace(1) %in0, i64 %retval.0.i
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
170 %arrayidx2 = getelementptr inbounds i8, ptr addrspace(1) %in1, i64 %retval.0.i
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
171 %arrayidx4 = getelementptr inbounds i8, ptr addrspace(1) %in2, i64 %retval.0.i
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
172 %l1 = load i8, ptr addrspace(1) %arrayidx, align 1
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
173 %l2 = load i8, ptr addrspace(1) %arrayidx2, align 1
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
174 %l3 = load i8, ptr addrspace(1) %arrayidx4, align 1
150
anatofuz
parents:
diff changeset
175 %conv1.i = sext i8 %l1 to i16
anatofuz
parents:
diff changeset
176 %conv3.i = sext i8 %l2 to i16
anatofuz
parents:
diff changeset
177 %conv5.i = sext i8 %l3 to i16
anatofuz
parents:
diff changeset
178 %mul.i.i.i = mul nsw i16 %conv3.i, %conv1.i
anatofuz
parents:
diff changeset
179 %add.i.i = add i16 %mul.i.i.i, %conv5.i
anatofuz
parents:
diff changeset
180 %c4 = icmp sgt i16 %add.i.i, -128
anatofuz
parents:
diff changeset
181 %cond.i.i = select i1 %c4, i16 %add.i.i, i16 -128
anatofuz
parents:
diff changeset
182 %c5 = icmp slt i16 %cond.i.i, 127
anatofuz
parents:
diff changeset
183 %cond13.i.i = select i1 %c5, i16 %cond.i.i, i16 127
anatofuz
parents:
diff changeset
184 %conv8.i = trunc i16 %cond13.i.i to i8
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
185 %arrayidx7 = getelementptr inbounds i8, ptr addrspace(1) %out, i64 %retval.0.i
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
186 store i8 %conv8.i, ptr addrspace(1) %arrayidx7, align 1
150
anatofuz
parents:
diff changeset
187 ret void
anatofuz
parents:
diff changeset
188 }
anatofuz
parents:
diff changeset
189
anatofuz
parents:
diff changeset
190 ; FUNC-LABEL: {{^}}i8_mad_32:
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
191 ; EG: MULLO_INT {{[* ]*}}T{{[0-9]}}.[[MAD_CHAN:[XYZW]]]
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
192 ; EG: ADD_INT {{[* ]*}}T{{[0-9]}}.[[MAD_CHAN:[XYZW]]]
150
anatofuz
parents:
diff changeset
193 ; The result must be sign-extended
anatofuz
parents:
diff changeset
194 ; EG: BFE_INT {{[* ]*}}T{{[0-9]\.[XYZW]}}, PV.[[MAD_CHAN]], 0.0, literal.x
anatofuz
parents:
diff changeset
195 ; EG: 8
anatofuz
parents:
diff changeset
196 ; SI: v_mad_u32_u24 [[MAD:v[0-9]]], {{[sv][0-9], [sv][0-9]}}
anatofuz
parents:
diff changeset
197 ; VI: v_mad_u16 [[MAD:v[0-9]]], {{[sv][0-9], [sv][0-9]}}
anatofuz
parents:
diff changeset
198 ; GCN: v_bfe_i32 [[EXT:v[0-9]]], [[MAD]], 0, 16
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
199 define amdgpu_kernel void @i8_mad_32(ptr addrspace(1) %out, ptr addrspace(1) %a, ptr addrspace(1) %b, ptr addrspace(1) %c, ptr addrspace(5) %idx) {
150
anatofuz
parents:
diff changeset
200 entry:
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
201 %retval.0.i = load i64, ptr addrspace(5) %idx
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
202 %arrayidx = getelementptr inbounds i8, ptr addrspace(1) %a, i64 %retval.0.i
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
203 %arrayidx2 = getelementptr inbounds i8, ptr addrspace(1) %b, i64 %retval.0.i
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
204 %arrayidx4 = getelementptr inbounds i8, ptr addrspace(1) %c, i64 %retval.0.i
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
205 %la = load i8, ptr addrspace(1) %arrayidx, align 1
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
206 %lb = load i8, ptr addrspace(1) %arrayidx2, align 1
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
207 %lc = load i8, ptr addrspace(1) %arrayidx4, align 1
150
anatofuz
parents:
diff changeset
208 %exta = sext i8 %la to i16
anatofuz
parents:
diff changeset
209 %extb = sext i8 %lb to i16
anatofuz
parents:
diff changeset
210 %extc = sext i8 %lc to i16
anatofuz
parents:
diff changeset
211 %mul = mul i16 %exta, %extb
anatofuz
parents:
diff changeset
212 %mad = add i16 %mul, %extc
anatofuz
parents:
diff changeset
213 %mad_ext = sext i16 %mad to i32
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
214 store i32 %mad_ext, ptr addrspace(1) %out
150
anatofuz
parents:
diff changeset
215 ret void
anatofuz
parents:
diff changeset
216 }
anatofuz
parents:
diff changeset
217
anatofuz
parents:
diff changeset
218 ; FUNC-LABEL: {{^}}i8_mad_64:
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
219 ; EG: MULLO_INT {{[* ]*}}T{{[0-9]}}.[[MAD_CHAN:[XYZW]]]
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
220 ; EG: ADD_INT {{[* ]*}}T{{[0-9]}}.[[MAD_CHAN:[XYZW]]]
150
anatofuz
parents:
diff changeset
221 ; The result must be sign-extended
anatofuz
parents:
diff changeset
222 ; EG: BFE_INT {{[* ]*}}T{{[0-9]\.[XYZW]}}, PV.[[MAD_CHAN]], 0.0, literal.x
anatofuz
parents:
diff changeset
223 ; EG: 8
anatofuz
parents:
diff changeset
224 ; SI: v_mad_u32_u24 [[MAD:v[0-9]]], {{[sv][0-9], [sv][0-9]}}
anatofuz
parents:
diff changeset
225 ; VI: v_mad_u16 [[MAD:v[0-9]]], {{[sv][0-9], [sv][0-9]}}
anatofuz
parents:
diff changeset
226 ; GCN: v_bfe_i32 [[EXT:v[0-9]]], [[MAD]], 0, 16
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
227 define amdgpu_kernel void @i8_mad_64(ptr addrspace(1) %out, ptr addrspace(1) %a, ptr addrspace(1) %b, ptr addrspace(1) %c, ptr addrspace(5) %idx) {
150
anatofuz
parents:
diff changeset
228 entry:
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
229 %retval.0.i = load i64, ptr addrspace(5) %idx
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
230 %arrayidx = getelementptr inbounds i8, ptr addrspace(1) %a, i64 %retval.0.i
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
231 %arrayidx2 = getelementptr inbounds i8, ptr addrspace(1) %b, i64 %retval.0.i
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
232 %arrayidx4 = getelementptr inbounds i8, ptr addrspace(1) %c, i64 %retval.0.i
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
233 %la = load i8, ptr addrspace(1) %arrayidx, align 1
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
234 %lb = load i8, ptr addrspace(1) %arrayidx2, align 1
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
235 %lc = load i8, ptr addrspace(1) %arrayidx4, align 1
150
anatofuz
parents:
diff changeset
236 %exta = sext i8 %la to i16
anatofuz
parents:
diff changeset
237 %extb = sext i8 %lb to i16
anatofuz
parents:
diff changeset
238 %extc = sext i8 %lc to i16
anatofuz
parents:
diff changeset
239 %mul = mul i16 %exta, %extb
anatofuz
parents:
diff changeset
240 %mad = add i16 %mul, %extc
anatofuz
parents:
diff changeset
241 %mad_ext = sext i16 %mad to i64
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
242 store i64 %mad_ext, ptr addrspace(1) %out
150
anatofuz
parents:
diff changeset
243 ret void
anatofuz
parents:
diff changeset
244 }
anatofuz
parents:
diff changeset
245
anatofuz
parents:
diff changeset
246 ; The ands are asserting the high bits are 0. SimplifyDemandedBits on
anatofuz
parents:
diff changeset
247 ; the adds would remove the ands before the target combine on the mul
anatofuz
parents:
diff changeset
248 ; had a chance to form mul24. The mul combine would then see
anatofuz
parents:
diff changeset
249 ; extractelement with no known bits and fail. All of the mul/add
anatofuz
parents:
diff changeset
250 ; combos in this loop should form v_mad_u32_u24.
anatofuz
parents:
diff changeset
251
anatofuz
parents:
diff changeset
252 ; FUNC-LABEL: {{^}}mad24_known_bits_destroyed:
anatofuz
parents:
diff changeset
253 ; GCN: v_mad_u32_u24
anatofuz
parents:
diff changeset
254 ; GCN: v_mad_u32_u24
anatofuz
parents:
diff changeset
255 ; GCN: v_mad_u32_u24
anatofuz
parents:
diff changeset
256 ; GCN: v_mad_u32_u24
anatofuz
parents:
diff changeset
257 ; GCN: v_mad_u32_u24
anatofuz
parents:
diff changeset
258 ; GCN: v_mad_u32_u24
anatofuz
parents:
diff changeset
259 ; GCN: v_mad_u32_u24
anatofuz
parents:
diff changeset
260 ; GCN: v_mad_u32_u24
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
261 define void @mad24_known_bits_destroyed(i32 %arg, <4 x i32> %arg1, <4 x i32> %arg2, <4 x i32> %arg3, i32 %arg4, i32 %arg5, i32 %arg6, ptr addrspace(1) %arg7, ptr addrspace(1) %arg8) #0 {
150
anatofuz
parents:
diff changeset
262 bb:
anatofuz
parents:
diff changeset
263 %tmp = and i32 %arg4, 16777215
anatofuz
parents:
diff changeset
264 %tmp9 = extractelement <4 x i32> %arg1, i64 1
anatofuz
parents:
diff changeset
265 %tmp10 = extractelement <4 x i32> %arg3, i64 1
anatofuz
parents:
diff changeset
266 %tmp11 = and i32 %tmp9, 16777215
anatofuz
parents:
diff changeset
267 %tmp12 = extractelement <4 x i32> %arg1, i64 2
anatofuz
parents:
diff changeset
268 %tmp13 = extractelement <4 x i32> %arg3, i64 2
anatofuz
parents:
diff changeset
269 %tmp14 = and i32 %tmp12, 16777215
anatofuz
parents:
diff changeset
270 %tmp15 = extractelement <4 x i32> %arg1, i64 3
anatofuz
parents:
diff changeset
271 %tmp16 = extractelement <4 x i32> %arg3, i64 3
anatofuz
parents:
diff changeset
272 %tmp17 = and i32 %tmp15, 16777215
anatofuz
parents:
diff changeset
273 br label %bb19
anatofuz
parents:
diff changeset
274
anatofuz
parents:
diff changeset
275 bb18: ; preds = %bb19
anatofuz
parents:
diff changeset
276 ret void
anatofuz
parents:
diff changeset
277
anatofuz
parents:
diff changeset
278 bb19: ; preds = %bb19, %bb
anatofuz
parents:
diff changeset
279 %tmp20 = phi i32 [ %arg, %bb ], [ %tmp40, %bb19 ]
anatofuz
parents:
diff changeset
280 %tmp21 = phi i32 [ 0, %bb ], [ %tmp54, %bb19 ]
anatofuz
parents:
diff changeset
281 %tmp22 = phi <4 x i32> [ %arg2, %bb ], [ %tmp53, %bb19 ]
anatofuz
parents:
diff changeset
282 %tmp23 = and i32 %tmp20, 16777215
anatofuz
parents:
diff changeset
283 %tmp24 = mul i32 %tmp23, %tmp
anatofuz
parents:
diff changeset
284 %tmp25 = add i32 %tmp24, %arg5
anatofuz
parents:
diff changeset
285 %tmp26 = extractelement <4 x i32> %tmp22, i64 1
anatofuz
parents:
diff changeset
286 %tmp27 = and i32 %tmp26, 16777215
anatofuz
parents:
diff changeset
287 %tmp28 = mul i32 %tmp27, %tmp11
anatofuz
parents:
diff changeset
288 %tmp29 = add i32 %tmp28, %tmp10
anatofuz
parents:
diff changeset
289 %tmp30 = extractelement <4 x i32> %tmp22, i64 2
anatofuz
parents:
diff changeset
290 %tmp31 = and i32 %tmp30, 16777215
anatofuz
parents:
diff changeset
291 %tmp32 = mul i32 %tmp31, %tmp14
anatofuz
parents:
diff changeset
292 %tmp33 = add i32 %tmp32, %tmp13
anatofuz
parents:
diff changeset
293 %tmp34 = extractelement <4 x i32> %tmp22, i64 3
anatofuz
parents:
diff changeset
294 %tmp35 = and i32 %tmp34, 16777215
anatofuz
parents:
diff changeset
295 %tmp36 = mul i32 %tmp35, %tmp17
anatofuz
parents:
diff changeset
296 %tmp37 = add i32 %tmp36, %tmp16
anatofuz
parents:
diff changeset
297 %tmp38 = and i32 %tmp25, 16777215
anatofuz
parents:
diff changeset
298 %tmp39 = mul i32 %tmp38, %tmp
anatofuz
parents:
diff changeset
299 %tmp40 = add i32 %tmp39, %arg5
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
300 store i32 %tmp40, ptr addrspace(1) %arg7
150
anatofuz
parents:
diff changeset
301 %tmp41 = insertelement <4 x i32> undef, i32 %tmp40, i32 0
anatofuz
parents:
diff changeset
302 %tmp42 = and i32 %tmp29, 16777215
anatofuz
parents:
diff changeset
303 %tmp43 = mul i32 %tmp42, %tmp11
anatofuz
parents:
diff changeset
304 %tmp44 = add i32 %tmp43, %tmp10
anatofuz
parents:
diff changeset
305 %tmp45 = insertelement <4 x i32> %tmp41, i32 %tmp44, i32 1
anatofuz
parents:
diff changeset
306 %tmp46 = and i32 %tmp33, 16777215
anatofuz
parents:
diff changeset
307 %tmp47 = mul i32 %tmp46, %tmp14
anatofuz
parents:
diff changeset
308 %tmp48 = add i32 %tmp47, %tmp13
anatofuz
parents:
diff changeset
309 %tmp49 = insertelement <4 x i32> %tmp45, i32 %tmp48, i32 2
anatofuz
parents:
diff changeset
310 %tmp50 = and i32 %tmp37, 16777215
anatofuz
parents:
diff changeset
311 %tmp51 = mul i32 %tmp50, %tmp17
anatofuz
parents:
diff changeset
312 %tmp52 = add i32 %tmp51, %tmp16
anatofuz
parents:
diff changeset
313 %tmp53 = insertelement <4 x i32> %tmp49, i32 %tmp52, i32 3
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
314 store <4 x i32> %tmp53, ptr addrspace(1) %arg8
150
anatofuz
parents:
diff changeset
315 %tmp54 = add nuw nsw i32 %tmp21, 1
anatofuz
parents:
diff changeset
316 %tmp55 = icmp eq i32 %tmp54, %arg6
anatofuz
parents:
diff changeset
317 br i1 %tmp55, label %bb18, label %bb19
anatofuz
parents:
diff changeset
318 }
anatofuz
parents:
diff changeset
319
anatofuz
parents:
diff changeset
320 attributes #0 = { norecurse nounwind }