1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370
|
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -mtriple aarch64 -run-pass=aarch64-prelegalizer-combiner -aarch64prelegalizercombiner-only-enable-rule="load_and_mask" -verify-machineinstrs %s -o - | FileCheck %s
# REQUIRES: asserts
# Check that we can fold and ({any,zext,sext}load, mask) -> zextload
---
name: test_anyext_1
tracksRegLiveness: true
body: |
bb.0:
liveins: $x0
; CHECK-LABEL: name: test_anyext_1
; CHECK: liveins: $x0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
; CHECK-NEXT: [[C:%[0-9]+]]:_(s8) = G_CONSTANT i8 1
; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s8) = G_LOAD [[COPY]](p0) :: (load (s8))
; CHECK-NEXT: [[AND:%[0-9]+]]:_(s8) = G_AND [[LOAD]], [[C]]
; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[AND]](s8)
; CHECK-NEXT: $w0 = COPY [[ANYEXT]](s32)
%0:_(p0) = COPY $x0
%1:_(s8) = G_CONSTANT i8 1
%2:_(s8) = G_LOAD %0 :: (load (s8))
%3:_(s8) = G_AND %2, %1
%4:_(s32) = G_ANYEXT %3
$w0 = COPY %4
...
---
name: test_anyext_s16
tracksRegLiveness: true
body: |
bb.0:
liveins: $x0
; CHECK-LABEL: name: test_anyext_s16
; CHECK: liveins: $x0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
; CHECK-NEXT: [[ZEXTLOAD:%[0-9]+]]:_(s16) = G_ZEXTLOAD [[COPY]](p0) :: (load (s8))
; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[ZEXTLOAD]](s16)
; CHECK-NEXT: $w0 = COPY [[ANYEXT]](s32)
%0:_(p0) = COPY $x0
%1:_(s16) = G_CONSTANT i16 255
%2:_(s16) = G_LOAD %0 :: (load (s8))
%3:_(s16) = G_AND %2, %1
%4:_(s32) = G_ANYEXT %3
$w0 = COPY %4
...
---
name: test_anyext_s32
tracksRegLiveness: true
body: |
bb.0:
liveins: $x0
; CHECK-LABEL: name: test_anyext_s32
; CHECK: liveins: $x0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
; CHECK-NEXT: [[ZEXTLOAD:%[0-9]+]]:_(s32) = G_ZEXTLOAD [[COPY]](p0) :: (load (s8))
; CHECK-NEXT: $w0 = COPY [[ZEXTLOAD]](s32)
%0:_(p0) = COPY $x0
%1:_(s32) = G_CONSTANT i32 255
%2:_(s32) = G_LOAD %0 :: (load (s8))
%3:_(s32) = G_AND %2, %1
$w0 = COPY %3
...
---
name: test_load_s32
tracksRegLiveness: true
body: |
bb.0:
liveins: $x0
; CHECK-LABEL: name: test_load_s32
; CHECK: liveins: $x0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
; CHECK-NEXT: [[ZEXTLOAD:%[0-9]+]]:_(s32) = G_ZEXTLOAD [[COPY]](p0) :: (load (s8), align 4)
; CHECK-NEXT: $w0 = COPY [[ZEXTLOAD]](s32)
%0:_(p0) = COPY $x0
%1:_(s32) = G_CONSTANT i32 255
%2:_(s32) = G_LOAD %0 :: (load (s32))
%3:_(s32) = G_AND %2, %1
$w0 = COPY %3
...
---
name: test_load_mask_s8_s32_atomic
tracksRegLiveness: true
body: |
bb.0:
liveins: $x0
; CHECK-LABEL: name: test_load_mask_s8_s32_atomic
; CHECK: liveins: $x0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[COPY]](p0) :: (load seq_cst (s32))
; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[LOAD]], [[C]]
; CHECK-NEXT: $w0 = COPY [[AND]](s32)
%0:_(p0) = COPY $x0
%1:_(s32) = G_CONSTANT i32 255
%2:_(s32) = G_LOAD %0 :: (load seq_cst (s32))
%3:_(s32) = G_AND %2, %1
$w0 = COPY %3
...
# The mask is equal to the memory size.
---
name: test_load_mask_s16_s16_atomic
tracksRegLiveness: true
body: |
bb.0:
liveins: $x0
; CHECK-LABEL: name: test_load_mask_s16_s16_atomic
; CHECK: liveins: $x0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
; CHECK-NEXT: [[ZEXTLOAD:%[0-9]+]]:_(s32) = G_ZEXTLOAD [[COPY]](p0) :: (load seq_cst (s16))
; CHECK-NEXT: $w0 = COPY [[ZEXTLOAD]](s32)
%0:_(p0) = COPY $x0
%1:_(s32) = G_CONSTANT i32 65535
%2:_(s32) = G_LOAD %0 :: (load seq_cst (s16))
%3:_(s32) = G_AND %2, %1
$w0 = COPY %3
...
# The mask is smaller than the memory size which must be preserved, so
# there's little point to folding.
---
name: test_load_mask_s8_s16_atomic
tracksRegLiveness: true
body: |
bb.0:
liveins: $x0
; CHECK-LABEL: name: test_load_mask_s8_s16_atomic
; CHECK: liveins: $x0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[COPY]](p0) :: (load seq_cst (s16))
; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[LOAD]], [[C]]
; CHECK-NEXT: $w0 = COPY [[AND]](s32)
%0:_(p0) = COPY $x0
%1:_(s32) = G_CONSTANT i32 255
%2:_(s32) = G_LOAD %0 :: (load seq_cst (s16))
%3:_(s32) = G_AND %2, %1
$w0 = COPY %3
...
---
name: test_load_mask_size_equals_dst_size
tracksRegLiveness: true
body: |
bb.0:
liveins: $x0
; The combine should only apply if the mask zeroes actual bits of the dst type
; If it doesn't, the mask is redundant and we have other combines to fold it away
; CHECK-LABEL: name: test_load_mask_size_equals_dst_size
; CHECK: liveins: $x0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -1
; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[COPY]](p0) :: (load (s32))
; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[LOAD]], [[C]]
; CHECK-NEXT: $w0 = COPY [[AND]](s32)
%0:_(p0) = COPY $x0
%1:_(s32) = G_CONSTANT i32 4294967295
%2:_(s32) = G_LOAD %0 :: (load (s32))
%3:_(s32) = G_AND %2, %1
$w0 = COPY %3
...
---
name: test_zext
tracksRegLiveness: true
body: |
bb.0:
liveins: $x0
; CHECK-LABEL: name: test_zext
; CHECK: liveins: $x0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
; CHECK-NEXT: [[ZEXTLOAD:%[0-9]+]]:_(s32) = G_ZEXTLOAD [[COPY]](p0) :: (load (s8), align 2)
; CHECK-NEXT: $w0 = COPY [[ZEXTLOAD]](s32)
%0:_(p0) = COPY $x0
%1:_(s32) = G_CONSTANT i32 255
%2:_(s32) = G_ZEXTLOAD %0 :: (load (s16))
%3:_(s32) = G_AND %2, %1
$w0 = COPY %3
...
---
name: test_zext_mask_larger_memsize
tracksRegLiveness: true
body: |
bb.0:
liveins: $x0
; The combine should only apply if the mask narrows the memory size.
; We have another combine that folds redundant masks
; CHECK-LABEL: name: test_zext_mask_larger_memsize
; CHECK: liveins: $x0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 65535
; CHECK-NEXT: [[ZEXTLOAD:%[0-9]+]]:_(s32) = G_ZEXTLOAD [[COPY]](p0) :: (load (s8))
; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[ZEXTLOAD]], [[C]]
; CHECK-NEXT: $w0 = COPY [[AND]](s32)
%0:_(p0) = COPY $x0
%1:_(s32) = G_CONSTANT i32 65535
%2:_(s32) = G_ZEXTLOAD %0 :: (load (s8))
%3:_(s32) = G_AND %2, %1
$w0 = COPY %3
...
---
name: test_sext
tracksRegLiveness: true
body: |
bb.0:
liveins: $x0
; CHECK-LABEL: name: test_sext
; CHECK: liveins: $x0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
; CHECK-NEXT: [[ZEXTLOAD:%[0-9]+]]:_(s32) = G_ZEXTLOAD [[COPY]](p0) :: (load (s8), align 2)
; CHECK-NEXT: $w0 = COPY [[ZEXTLOAD]](s32)
%0:_(p0) = COPY $x0
%1:_(s32) = G_CONSTANT i32 255
%2:_(s32) = G_SEXTLOAD %0 :: (load (s16))
%3:_(s32) = G_AND %2, %1
$w0 = COPY %3
...
---
name: test_sext_mask_larger_memsize
tracksRegLiveness: true
body: |
bb.0:
liveins: $x0
; CHECK-LABEL: name: test_sext_mask_larger_memsize
; CHECK: liveins: $x0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 65535
; CHECK-NEXT: [[SEXTLOAD:%[0-9]+]]:_(s32) = G_SEXTLOAD [[COPY]](p0) :: (load (s8))
; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[SEXTLOAD]], [[C]]
; CHECK-NEXT: $w0 = COPY [[AND]](s32)
%0:_(p0) = COPY $x0
%1:_(s32) = G_CONSTANT i32 65535
%2:_(s32) = G_SEXTLOAD %0 :: (load (s8))
%3:_(s32) = G_AND %2, %1
$w0 = COPY %3
...
---
name: test_non_pow2_memtype
tracksRegLiveness: true
body: |
bb.0:
liveins: $x0
; CHECK-LABEL: name: test_non_pow2_memtype
; CHECK: liveins: $x0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
; CHECK-NEXT: [[C:%[0-9]+]]:_(s24) = G_CONSTANT i24 7
; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s24) = G_LOAD [[COPY]](p0) :: (load (s24), align 4)
; CHECK-NEXT: [[AND:%[0-9]+]]:_(s24) = G_AND [[LOAD]], [[C]]
; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[AND]](s24)
; CHECK-NEXT: $w0 = COPY [[ANYEXT]](s32)
%0:_(p0) = COPY $x0
%1:_(s24) = G_CONSTANT i24 7
%2:_(s24) = G_LOAD %0 :: (load (s24))
%3:_(s24) = G_AND %2, %1
%4:_(s32) = G_ANYEXT %3
$w0 = COPY %4
...
---
name: test_no_mask
tracksRegLiveness: true
body: |
bb.0:
liveins: $x0
; CHECK-LABEL: name: test_no_mask
; CHECK: liveins: $x0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 510
; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[COPY]](p0) :: (load (s8))
; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[LOAD]], [[C]]
; CHECK-NEXT: $w0 = COPY [[AND]](s32)
%0:_(p0) = COPY $x0
%1:_(s32) = G_CONSTANT i32 510
%2:_(s32) = G_LOAD %0 :: (load (s8))
%3:_(s32) = G_AND %2, %1
$w0 = COPY %3
...
---
name: test_volatile
tracksRegLiveness: true
body: |
bb.0:
liveins: $x0
; CHECK-LABEL: name: test_volatile
; CHECK: liveins: $x0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
; CHECK-NEXT: [[ZEXTLOAD:%[0-9]+]]:_(s32) = G_ZEXTLOAD [[COPY]](p0) :: (volatile load (s8))
; CHECK-NEXT: $w0 = COPY [[ZEXTLOAD]](s32)
%0:_(p0) = COPY $x0
%1:_(s32) = G_CONSTANT i32 255
%2:_(s32) = G_LOAD %0 :: (volatile load (s8))
%3:_(s32) = G_AND %2, %1
$w0 = COPY %3
...
---
name: test_volatile_mask_smaller_mem
tracksRegLiveness: true
body: |
bb.0:
liveins: $x0
; CHECK-LABEL: name: test_volatile_mask_smaller_mem
; CHECK: liveins: $x0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[COPY]](p0) :: (volatile load (s16))
; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[LOAD]], [[C]]
; CHECK-NEXT: $w0 = COPY [[AND]](s32)
%0:_(p0) = COPY $x0
%1:_(s32) = G_CONSTANT i32 255
%2:_(s32) = G_LOAD %0 :: (volatile load (s16))
%3:_(s32) = G_AND %2, %1
$w0 = COPY %3
...
---
name: test_no_lookthrough_copies_multi_uses
tracksRegLiveness: true
body: |
bb.0:
liveins: $x0
; CHECK-LABEL: name: test_no_lookthrough_copies_multi_uses
; CHECK: liveins: $x0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[COPY]](p0) :: (load (s16))
; CHECK-NEXT: %v:_(s32) = G_ASSERT_ZEXT [[LOAD]], 16
; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND %v, [[C]]
; CHECK-NEXT: $w1 = COPY %v(s32)
; CHECK-NEXT: $w0 = COPY [[AND]](s32)
%0:_(p0) = COPY $x0
%1:_(s32) = G_CONSTANT i32 255
%2:_(s32) = G_LOAD %0 :: (load (s16))
%v:_(s32) = G_ASSERT_ZEXT %2, 16
%3:_(s32) = G_AND %v, %1
$w1 = COPY %v
$w0 = COPY %3
...
|