1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py 2# RUN: llc -mtriple=amdgcn-mesa-mesa3d -mcpu=tahiti -run-pass=amdgpu-postlegalizer-combiner -verify-machineinstrs %s -o - | FileCheck -check-prefix=GFX6 %s 3# RUN: llc -mtriple=amdgcn-mesa-mesa3d -mcpu=gfx900 -run-pass=amdgpu-postlegalizer-combiner -verify-machineinstrs %s -o - | FileCheck -check-prefix=GFX9 %s 4 5# Can't narrow this; need known bits 6--- 7name: shl_s64_by_2_from_anyext_s32 8tracksRegLiveness: true 9legalized: true 10body: | 11 bb.0: 12 liveins: $vgpr0 13 14 ; GFX6-LABEL: name: shl_s64_by_2_from_anyext_s32 15 ; GFX6: liveins: $vgpr0 16 ; GFX6: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0 17 ; GFX6: [[ANYEXT:%[0-9]+]]:_(s64) = G_ANYEXT [[COPY]](s32) 18 ; GFX6: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 2 19 ; GFX6: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[ANYEXT]], [[C]](s32) 20 ; GFX6: $vgpr0_vgpr1 = COPY [[SHL]](s64) 21 ; GFX9-LABEL: name: shl_s64_by_2_from_anyext_s32 22 ; GFX9: liveins: $vgpr0 23 ; GFX9: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0 24 ; GFX9: [[ANYEXT:%[0-9]+]]:_(s64) = G_ANYEXT [[COPY]](s32) 25 ; GFX9: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 2 26 ; GFX9: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[ANYEXT]], [[C]](s32) 27 ; GFX9: $vgpr0_vgpr1 = COPY [[SHL]](s64) 28 %0:_(s32) = COPY $vgpr0 29 %1:_(s64) = G_ANYEXT %0 30 %2:_(s32) = G_CONSTANT i32 2 31 %3:_(s64) = G_SHL %1, %2 32 $vgpr0_vgpr1 = COPY %3 33... 34 35# Can't narrow this; need known bits 36--- 37name: shl_s64_by_2_from_sext_s32 38tracksRegLiveness: true 39legalized: true 40body: | 41 bb.0: 42 liveins: $vgpr0 43 44 ; GFX6-LABEL: name: shl_s64_by_2_from_sext_s32 45 ; GFX6: liveins: $vgpr0 46 ; GFX6: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0 47 ; GFX6: [[SEXT:%[0-9]+]]:_(s64) = G_SEXT [[COPY]](s32) 48 ; GFX6: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 2 49 ; GFX6: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[SEXT]], [[C]](s32) 50 ; GFX6: $vgpr0_vgpr1 = COPY [[SHL]](s64) 51 ; GFX9-LABEL: name: shl_s64_by_2_from_sext_s32 52 ; GFX9: liveins: $vgpr0 53 ; GFX9: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0 54 ; GFX9: [[SEXT:%[0-9]+]]:_(s64) = G_SEXT [[COPY]](s32) 55 ; GFX9: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 2 56 ; GFX9: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[SEXT]], [[C]](s32) 57 ; GFX9: $vgpr0_vgpr1 = COPY [[SHL]](s64) 58 %0:_(s32) = COPY $vgpr0 59 %1:_(s64) = G_SEXT %0 60 %2:_(s32) = G_CONSTANT i32 2 61 %3:_(s64) = G_SHL %1, %2 62 $vgpr0_vgpr1 = COPY %3 63... 64 65# Can't narrow this; need known bits 66--- 67name: shl_s64_by_2_from_zext_s32 68tracksRegLiveness: true 69legalized: true 70body: | 71 bb.0: 72 liveins: $vgpr0 73 74 ; GFX6-LABEL: name: shl_s64_by_2_from_zext_s32 75 ; GFX6: liveins: $vgpr0 76 ; GFX6: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0 77 ; GFX6: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY]](s32) 78 ; GFX6: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 2 79 ; GFX6: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[ZEXT]], [[C]](s32) 80 ; GFX6: $vgpr0_vgpr1 = COPY [[SHL]](s64) 81 ; GFX9-LABEL: name: shl_s64_by_2_from_zext_s32 82 ; GFX9: liveins: $vgpr0 83 ; GFX9: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0 84 ; GFX9: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY]](s32) 85 ; GFX9: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 2 86 ; GFX9: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[ZEXT]], [[C]](s32) 87 ; GFX9: $vgpr0_vgpr1 = COPY [[SHL]](s64) 88 %0:_(s32) = COPY $vgpr0 89 %1:_(s64) = G_ZEXT %0 90 %2:_(s32) = G_CONSTANT i32 2 91 %3:_(s64) = G_SHL %1, %2 92 $vgpr0_vgpr1 = COPY %3 93... 94 95--- 96name: narrow_shl_s64_by_2_from_anyext_s32 97tracksRegLiveness: true 98legalized: true 99body: | 100 bb.0: 101 liveins: $vgpr0 102 103 ; GFX6-LABEL: name: narrow_shl_s64_by_2_from_anyext_s32 104 ; GFX6: liveins: $vgpr0 105 ; GFX6: %narrow:_(s32) = COPY $vgpr0 106 ; GFX6: %masklow30:_(s32) = G_CONSTANT i32 1073741823 107 ; GFX6: %masked:_(s32) = G_AND %narrow, %masklow30 108 ; GFX6: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 2 109 ; GFX6: [[SHL:%[0-9]+]]:_(s32) = G_SHL %masked, [[C]](s32) 110 ; GFX6: %shl:_(s64) = G_ZEXT [[SHL]](s32) 111 ; GFX6: $vgpr0_vgpr1 = COPY %shl(s64) 112 ; GFX9-LABEL: name: narrow_shl_s64_by_2_from_anyext_s32 113 ; GFX9: liveins: $vgpr0 114 ; GFX9: %narrow:_(s32) = COPY $vgpr0 115 ; GFX9: %masklow30:_(s32) = G_CONSTANT i32 1073741823 116 ; GFX9: %masked:_(s32) = G_AND %narrow, %masklow30 117 ; GFX9: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 2 118 ; GFX9: [[SHL:%[0-9]+]]:_(s32) = G_SHL %masked, [[C]](s32) 119 ; GFX9: %shl:_(s64) = G_ZEXT [[SHL]](s32) 120 ; GFX9: $vgpr0_vgpr1 = COPY %shl(s64) 121 %narrow:_(s32) = COPY $vgpr0 122 %masklow30:_(s32) = G_CONSTANT i32 1073741823 123 %masked:_(s32) = G_AND %narrow, %masklow30 124 %extend:_(s64) = G_ANYEXT %masked 125 %shiftamt:_(s32) = G_CONSTANT i32 2 126 %shl:_(s64) = G_SHL %extend, %shiftamt 127 $vgpr0_vgpr1 = COPY %shl 128... 129 130--- 131name: narrow_shl_s64_by_2_from_zext_s32 132tracksRegLiveness: true 133legalized: true 134body: | 135 bb.0: 136 liveins: $vgpr0 137 138 ; GFX6-LABEL: name: narrow_shl_s64_by_2_from_zext_s32 139 ; GFX6: liveins: $vgpr0 140 ; GFX6: %narrow:_(s32) = COPY $vgpr0 141 ; GFX6: %masklow30:_(s32) = G_CONSTANT i32 1073741823 142 ; GFX6: %masked:_(s32) = G_AND %narrow, %masklow30 143 ; GFX6: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 2 144 ; GFX6: [[SHL:%[0-9]+]]:_(s32) = G_SHL %masked, [[C]](s32) 145 ; GFX6: %shl:_(s64) = G_ZEXT [[SHL]](s32) 146 ; GFX6: $vgpr0_vgpr1 = COPY %shl(s64) 147 ; GFX9-LABEL: name: narrow_shl_s64_by_2_from_zext_s32 148 ; GFX9: liveins: $vgpr0 149 ; GFX9: %narrow:_(s32) = COPY $vgpr0 150 ; GFX9: %masklow30:_(s32) = G_CONSTANT i32 1073741823 151 ; GFX9: %masked:_(s32) = G_AND %narrow, %masklow30 152 ; GFX9: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 2 153 ; GFX9: [[SHL:%[0-9]+]]:_(s32) = G_SHL %masked, [[C]](s32) 154 ; GFX9: %shl:_(s64) = G_ZEXT [[SHL]](s32) 155 ; GFX9: $vgpr0_vgpr1 = COPY %shl(s64) 156 %narrow:_(s32) = COPY $vgpr0 157 %masklow30:_(s32) = G_CONSTANT i32 1073741823 158 %masked:_(s32) = G_AND %narrow, %masklow30 159 %extend:_(s64) = G_ZEXT %masked 160 %shiftamt:_(s32) = G_CONSTANT i32 2 161 %shl:_(s64) = G_SHL %extend, %shiftamt 162 $vgpr0_vgpr1 = COPY %shl 163... 164 165--- 166name: narrow_shl_s64_by_2_from_sext_s32 167tracksRegLiveness: true 168legalized: true 169body: | 170 bb.0: 171 liveins: $vgpr0 172 173 ; GFX6-LABEL: name: narrow_shl_s64_by_2_from_sext_s32 174 ; GFX6: liveins: $vgpr0 175 ; GFX6: %narrow:_(s32) = COPY $vgpr0 176 ; GFX6: %masklow30:_(s32) = G_CONSTANT i32 1073741823 177 ; GFX6: %masked:_(s32) = G_AND %narrow, %masklow30 178 ; GFX6: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 2 179 ; GFX6: [[SHL:%[0-9]+]]:_(s32) = G_SHL %masked, [[C]](s32) 180 ; GFX6: %shl:_(s64) = G_ZEXT [[SHL]](s32) 181 ; GFX6: $vgpr0_vgpr1 = COPY %shl(s64) 182 ; GFX9-LABEL: name: narrow_shl_s64_by_2_from_sext_s32 183 ; GFX9: liveins: $vgpr0 184 ; GFX9: %narrow:_(s32) = COPY $vgpr0 185 ; GFX9: %masklow30:_(s32) = G_CONSTANT i32 1073741823 186 ; GFX9: %masked:_(s32) = G_AND %narrow, %masklow30 187 ; GFX9: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 2 188 ; GFX9: [[SHL:%[0-9]+]]:_(s32) = G_SHL %masked, [[C]](s32) 189 ; GFX9: %shl:_(s64) = G_ZEXT [[SHL]](s32) 190 ; GFX9: $vgpr0_vgpr1 = COPY %shl(s64) 191 %narrow:_(s32) = COPY $vgpr0 192 %masklow30:_(s32) = G_CONSTANT i32 1073741823 193 %masked:_(s32) = G_AND %narrow, %masklow30 194 %extend:_(s64) = G_SEXT %masked 195 %shiftamt:_(s32) = G_CONSTANT i32 2 196 %shl:_(s64) = G_SHL %extend, %shiftamt 197 $vgpr0_vgpr1 = COPY %shl 198... 199 200--- 201name: narrow_shl_s64_by_2_from_zext_s32_lookthrough_amount 202tracksRegLiveness: true 203legalized: true 204body: | 205 bb.0: 206 liveins: $vgpr0 207 208 ; GFX6-LABEL: name: narrow_shl_s64_by_2_from_zext_s32_lookthrough_amount 209 ; GFX6: liveins: $vgpr0 210 ; GFX6: %narrow:_(s32) = COPY $vgpr0 211 ; GFX6: %masklow30:_(s32) = G_CONSTANT i32 1073741823 212 ; GFX6: %masked:_(s32) = G_AND %narrow, %masklow30 213 ; GFX6: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 2 214 ; GFX6: [[SHL:%[0-9]+]]:_(s32) = G_SHL %masked, [[C]](s32) 215 ; GFX6: %shl:_(s64) = G_ZEXT [[SHL]](s32) 216 ; GFX6: $vgpr0_vgpr1 = COPY %shl(s64) 217 ; GFX9-LABEL: name: narrow_shl_s64_by_2_from_zext_s32_lookthrough_amount 218 ; GFX9: liveins: $vgpr0 219 ; GFX9: %narrow:_(s32) = COPY $vgpr0 220 ; GFX9: %masklow30:_(s32) = G_CONSTANT i32 1073741823 221 ; GFX9: %masked:_(s32) = G_AND %narrow, %masklow30 222 ; GFX9: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 2 223 ; GFX9: [[SHL:%[0-9]+]]:_(s32) = G_SHL %masked, [[C]](s32) 224 ; GFX9: %shl:_(s64) = G_ZEXT [[SHL]](s32) 225 ; GFX9: $vgpr0_vgpr1 = COPY %shl(s64) 226 %narrow:_(s32) = COPY $vgpr0 227 %masklow30:_(s32) = G_CONSTANT i32 1073741823 228 %masked:_(s32) = G_AND %narrow, %masklow30 229 %extend:_(s64) = G_ZEXT %masked 230 %shiftamt64:_(s64) = G_CONSTANT i64 2 231 %shiftamt:_(s32) = G_TRUNC %shiftamt64 232 %shl:_(s64) = G_SHL %extend, %shiftamt 233 $vgpr0_vgpr1 = COPY %shl 234... 235 236# Can't introduce a 16-bit shift before gfx8 237--- 238name: narrow_shl_s32_by_2_from_zext_s16 239tracksRegLiveness: true 240legalized: true 241body: | 242 bb.0: 243 liveins: $vgpr0 244 245 ; GFX6-LABEL: name: narrow_shl_s32_by_2_from_zext_s16 246 ; GFX6: liveins: $vgpr0 247 ; GFX6: %argument:_(s32) = COPY $vgpr0 248 ; GFX6: %narrow:_(s16) = G_TRUNC %argument(s32) 249 ; GFX6: %masklow14:_(s16) = G_CONSTANT i16 16383 250 ; GFX6: %masked:_(s16) = G_AND %narrow, %masklow14 251 ; GFX6: %extend:_(s32) = G_ZEXT %masked(s16) 252 ; GFX6: %shiftamt:_(s32) = G_CONSTANT i32 2 253 ; GFX6: %shl:_(s32) = G_SHL %extend, %shiftamt(s32) 254 ; GFX6: $vgpr0 = COPY %shl(s32) 255 ; GFX9-LABEL: name: narrow_shl_s32_by_2_from_zext_s16 256 ; GFX9: liveins: $vgpr0 257 ; GFX9: %argument:_(s32) = COPY $vgpr0 258 ; GFX9: %narrow:_(s16) = G_TRUNC %argument(s32) 259 ; GFX9: %masklow14:_(s16) = G_CONSTANT i16 16383 260 ; GFX9: %masked:_(s16) = G_AND %narrow, %masklow14 261 ; GFX9: [[C:%[0-9]+]]:_(s16) = G_CONSTANT i16 2 262 ; GFX9: [[SHL:%[0-9]+]]:_(s16) = G_SHL %masked, [[C]](s16) 263 ; GFX9: %shl:_(s32) = G_ZEXT [[SHL]](s16) 264 ; GFX9: $vgpr0 = COPY %shl(s32) 265 %argument:_(s32) = COPY $vgpr0 266 %narrow:_(s16) = G_TRUNC %argument 267 %masklow14:_(s16) = G_CONSTANT i16 16383 268 %masked:_(s16) = G_AND %narrow, %masklow14 269 %extend:_(s32) = G_ZEXT %masked 270 %shiftamt:_(s32) = G_CONSTANT i32 2 271 %shl:_(s32) = G_SHL %extend, %shiftamt 272 $vgpr0 = COPY %shl 273... 274 275--- 276name: narrow_shl_s64_by_2_from_zext_s16 277tracksRegLiveness: true 278legalized: true 279body: | 280 bb.0: 281 liveins: $vgpr0 282 283 ; GFX6-LABEL: name: narrow_shl_s64_by_2_from_zext_s16 284 ; GFX6: liveins: $vgpr0 285 ; GFX6: %argument:_(s32) = COPY $vgpr0 286 ; GFX6: %narrow:_(s16) = G_TRUNC %argument(s32) 287 ; GFX6: %masklow14:_(s16) = G_CONSTANT i16 16383 288 ; GFX6: %masked:_(s16) = G_AND %narrow, %masklow14 289 ; GFX6: %extend:_(s64) = G_ZEXT %masked(s16) 290 ; GFX6: %shiftamt:_(s32) = G_CONSTANT i32 2 291 ; GFX6: %shl:_(s64) = G_SHL %extend, %shiftamt(s32) 292 ; GFX6: $vgpr0_vgpr1 = COPY %shl(s64) 293 ; GFX9-LABEL: name: narrow_shl_s64_by_2_from_zext_s16 294 ; GFX9: liveins: $vgpr0 295 ; GFX9: %argument:_(s32) = COPY $vgpr0 296 ; GFX9: %narrow:_(s16) = G_TRUNC %argument(s32) 297 ; GFX9: %masklow14:_(s16) = G_CONSTANT i16 16383 298 ; GFX9: %masked:_(s16) = G_AND %narrow, %masklow14 299 ; GFX9: [[C:%[0-9]+]]:_(s16) = G_CONSTANT i16 2 300 ; GFX9: [[SHL:%[0-9]+]]:_(s16) = G_SHL %masked, [[C]](s16) 301 ; GFX9: %shl:_(s64) = G_ZEXT [[SHL]](s16) 302 ; GFX9: $vgpr0_vgpr1 = COPY %shl(s64) 303 %argument:_(s32) = COPY $vgpr0 304 %narrow:_(s16) = G_TRUNC %argument 305 %masklow14:_(s16) = G_CONSTANT i16 16383 306 %masked:_(s16) = G_AND %narrow, %masklow14 307 %extend:_(s64) = G_ZEXT %masked 308 %shiftamt:_(s32) = G_CONSTANT i32 2 309 %shl:_(s64) = G_SHL %extend, %shiftamt 310 $vgpr0_vgpr1 = COPY %shl 311... 312