1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=amdgcn -run-pass=amdgpu-prelegalizer-combiner -verify-machineinstrs %s -o - | FileCheck %s
6 tracksRegLiveness: true
9 ; CHECK-LABEL: name: test_const_const
10 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 15
11 ; CHECK-NEXT: $sgpr0 = COPY [[C]](s32)
12 ; CHECK-NEXT: SI_RETURN_TO_EPILOG implicit $sgpr0
13 %0:_(s32) = G_CONSTANT i32 15
14 %1:_(s32) = G_CONSTANT i32 255
15 %2:_(s32) = G_AND %0(s32), %1(s32)
17 SI_RETURN_TO_EPILOG implicit $sgpr0
21 name: test_const_const_2
22 tracksRegLiveness: true
25 ; CHECK-LABEL: name: test_const_const_2
26 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 15
27 ; CHECK-NEXT: $sgpr0 = COPY [[C]](s32)
28 ; CHECK-NEXT: SI_RETURN_TO_EPILOG implicit $sgpr0
29 %0:_(s32) = G_CONSTANT i32 255
30 %1:_(s32) = G_CONSTANT i32 15
31 %2:_(s32) = G_AND %0(s32), %1(s32)
33 SI_RETURN_TO_EPILOG implicit $sgpr0
37 name: test_const_const_3
38 tracksRegLiveness: true
41 ; CHECK-LABEL: name: test_const_const_3
42 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -1431655766
43 ; CHECK-NEXT: $vgpr0 = COPY [[C]](s32)
44 ; CHECK-NEXT: SI_RETURN_TO_EPILOG implicit $vgpr0
45 %0:_(s32) = G_CONSTANT i32 2863311530
46 %1:_(s32) = G_CONSTANT i32 4008636142
47 %2:_(s32) = G_AND %0(s32), %1(s32)
49 SI_RETURN_TO_EPILOG implicit $vgpr0
54 tracksRegLiveness: true
59 ; CHECK-LABEL: name: test_and_and
60 ; CHECK: liveins: $vgpr0
62 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
63 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 15
64 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY]], [[C]]
65 ; CHECK-NEXT: $vgpr0 = COPY [[AND]](s32)
66 ; CHECK-NEXT: SI_RETURN_TO_EPILOG implicit $vgpr0
67 %0:_(s32) = COPY $vgpr0
68 %1:_(s32) = G_CONSTANT i32 15
69 %2:_(s32) = G_CONSTANT i32 255
70 %3:_(s32) = G_AND %0, %1(s32)
71 %4:_(s32) = G_AND %3, %2
73 SI_RETURN_TO_EPILOG implicit $vgpr0
78 tracksRegLiveness: true
83 ; CHECK-LABEL: name: test_shl_and
84 ; CHECK: liveins: $sgpr0
86 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $sgpr0
87 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 5
88 ; CHECK-NEXT: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY]], [[C]](s32)
89 ; CHECK-NEXT: $sgpr0 = COPY [[SHL]](s32)
90 ; CHECK-NEXT: SI_RETURN_TO_EPILOG implicit $sgpr0
91 %0:_(s32) = COPY $sgpr0
92 %1:_(s32) = G_CONSTANT i32 5
93 %2:_(s32) = G_CONSTANT i32 4294967264
94 %3:_(s32) = G_SHL %0, %1(s32)
95 %4:_(s32) = G_AND %3, %2
97 SI_RETURN_TO_EPILOG implicit $sgpr0
102 tracksRegLiveness: true
107 ; CHECK-LABEL: name: test_lshr_and
108 ; CHECK: liveins: $vgpr0
110 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
111 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 5
112 ; CHECK-NEXT: [[LSHR:%[0-9]+]]:_(s32) = G_LSHR [[COPY]], [[C]](s32)
113 ; CHECK-NEXT: $vgpr0 = COPY [[LSHR]](s32)
114 ; CHECK-NEXT: SI_RETURN_TO_EPILOG implicit $vgpr0
115 %0:_(s32) = COPY $vgpr0
116 %1:_(s32) = G_CONSTANT i32 5
117 %2:_(s32) = G_CONSTANT i32 134217727
118 %3:_(s32) = G_LSHR %0, %1(s32)
119 %4:_(s32) = G_AND %3, %2
120 $vgpr0 = COPY %4(s32)
121 SI_RETURN_TO_EPILOG implicit $vgpr0
125 name: test_and_non_const
126 tracksRegLiveness: true
129 liveins: $sgpr0, $sgpr1
131 ; CHECK-LABEL: name: test_and_non_const
132 ; CHECK: liveins: $sgpr0, $sgpr1
134 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $sgpr0
135 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16
136 ; CHECK-NEXT: [[LSHR:%[0-9]+]]:_(s32) = G_LSHR [[COPY]], [[C]](s32)
137 ; CHECK-NEXT: $sgpr0 = COPY [[LSHR]](s32)
138 ; CHECK-NEXT: SI_RETURN_TO_EPILOG implicit $sgpr0
139 %0:_(s32) = COPY $sgpr0
140 %1:_(s32) = COPY $sgpr1
141 %2:_(s32) = G_CONSTANT i32 16
142 %3:_(s32) = G_CONSTANT i32 65535
143 %4:_(s32) = G_OR %1, %3
144 %5:_(s32) = G_LSHR %0, %2(s32)
145 %6:_(s32) = G_AND %5, %4
146 $sgpr0 = COPY %6(s32)
147 SI_RETURN_TO_EPILOG implicit $sgpr0
150 name: test_sext_inreg
151 tracksRegLiveness: true
154 ; CHECK-LABEL: name: test_sext_inreg
155 ; CHECK: %cst_1:_(s32) = G_CONSTANT i32 -5
156 ; CHECK-NEXT: $sgpr0 = COPY %cst_1(s32)
157 ; CHECK-NEXT: SI_RETURN_TO_EPILOG implicit $sgpr0
158 %cst_1:_(s32) = G_CONSTANT i32 -5
161 %cst_11:_(s32) = G_CONSTANT i32 11
163 ; Sext from the 4th bit -> 111 ... 1011 = -5
164 %sext_inreg_11:_(s32) = G_SEXT_INREG %cst_11, 4
166 %and:_(s32) = G_AND %cst_1(s32), %sext_inreg_11(s32)
167 $sgpr0 = COPY %and(s32)
168 SI_RETURN_TO_EPILOG implicit $sgpr0
171 name: vector_const_splat_const_splat
172 tracksRegLiveness: true
175 ; CHECK-LABEL: name: vector_const_splat_const_splat
176 ; CHECK: %fifteen:_(s16) = G_CONSTANT i16 15
177 ; CHECK-NEXT: %c1:_(<2 x s16>) = G_BUILD_VECTOR %fifteen(s16), %fifteen(s16)
178 ; CHECK-NEXT: $vgpr0 = COPY %c1(<2 x s16>)
179 ; CHECK-NEXT: SI_RETURN_TO_EPILOG implicit $vgpr0
180 %fifteen:_(s16) = G_CONSTANT i16 15
181 %mask:_(s16) = G_CONSTANT i16 255
182 %c1:_(<2 x s16>) = G_BUILD_VECTOR %fifteen, %fifteen
183 %c2:_(<2 x s16>) = G_BUILD_VECTOR %mask, %mask
184 %and:_(<2 x s16>) = G_AND %c1(<2 x s16>), %c2(<2 x s16>)
185 $vgpr0 = COPY %and(<2 x s16>)
186 SI_RETURN_TO_EPILOG implicit $vgpr0
189 name: vector_const_valid_not_splat
190 tracksRegLiveness: true
193 ; CHECK-LABEL: name: vector_const_valid_not_splat
194 ; CHECK: %fifteen:_(s16) = G_CONSTANT i16 15
195 ; CHECK-NEXT: %sixteen:_(s16) = G_CONSTANT i16 16
196 ; CHECK-NEXT: %c1:_(<2 x s16>) = G_BUILD_VECTOR %fifteen(s16), %sixteen(s16)
197 ; CHECK-NEXT: $vgpr0 = COPY %c1(<2 x s16>)
198 ; CHECK-NEXT: SI_RETURN_TO_EPILOG implicit $vgpr0
199 %fifteen:_(s16) = G_CONSTANT i16 15
200 %sixteen:_(s16) = G_CONSTANT i16 16
201 %mask:_(s16) = G_CONSTANT i16 255
202 %c1:_(<2 x s16>) = G_BUILD_VECTOR %fifteen, %sixteen
203 %c2:_(<2 x s16>) = G_BUILD_VECTOR %mask, %mask
204 %and:_(<2 x s16>) = G_AND %c1(<2 x s16>), %c2(<2 x s16>)
205 $vgpr0 = COPY %and(<2 x s16>)
206 SI_RETURN_TO_EPILOG implicit $vgpr0
209 name: vector_dont_combine_const_too_wide
210 tracksRegLiveness: true
213 ; CHECK-LABEL: name: vector_dont_combine_const_too_wide
214 ; CHECK: %fifteen:_(s16) = G_CONSTANT i16 15
215 ; CHECK-NEXT: %too_wide:_(s16) = G_CONSTANT i16 257
216 ; CHECK-NEXT: %mask:_(s16) = G_CONSTANT i16 255
217 ; CHECK-NEXT: %c1:_(<2 x s16>) = G_BUILD_VECTOR %fifteen(s16), %too_wide(s16)
218 ; CHECK-NEXT: %c2:_(<2 x s16>) = G_BUILD_VECTOR %mask(s16), %mask(s16)
219 ; CHECK-NEXT: %and:_(<2 x s16>) = G_AND %c1, %c2
220 ; CHECK-NEXT: $vgpr0 = COPY %and(<2 x s16>)
221 ; CHECK-NEXT: SI_RETURN_TO_EPILOG implicit $vgpr0
222 %fifteen:_(s16) = G_CONSTANT i16 15
223 %too_wide:_(s16) = G_CONSTANT i16 257
224 %mask:_(s16) = G_CONSTANT i16 255
225 %c1:_(<2 x s16>) = G_BUILD_VECTOR %fifteen, %too_wide
226 %c2:_(<2 x s16>) = G_BUILD_VECTOR %mask, %mask
227 %and:_(<2 x s16>) = G_AND %c1(<2 x s16>), %c2(<2 x s16>)
228 $vgpr0 = COPY %and(<2 x s16>)
229 SI_RETURN_TO_EPILOG implicit $vgpr0