Files
TheRock/compiler/amd-llvm/llvm/test/CodeGen/AArch64/GlobalISel/combine-constant-fold-unary-int.mir
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

401 lines
12 KiB
YAML

# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -mtriple aarch64 -run-pass=aarch64-prelegalizer-combiner %s -o - | FileCheck %s
---
name: ctlz_s32
body: |
bb.0:
; CHECK-LABEL: name: ctlz_s32
; CHECK: %res:_(s32) = G_CONSTANT i32 28
; CHECK-NEXT: $w0 = COPY %res(s32)
; CHECK-NEXT: RET_ReallyLR implicit $w0
%a:_(s32) = G_CONSTANT i32 8
%res:_(s32) = G_CTLZ %a
$w0 = COPY %res(s32)
RET_ReallyLR implicit $w0
...
---
name: ctlz_s32_zero
body: |
bb.0:
; CHECK-LABEL: name: ctlz_s32_zero
; CHECK: %res:_(s32) = G_CONSTANT i32 32
; CHECK-NEXT: $w0 = COPY %res(s32)
; CHECK-NEXT: RET_ReallyLR implicit $w0
%a:_(s32) = G_CONSTANT i32 0
%res:_(s32) = G_CTLZ %a
$w0 = COPY %res(s32)
RET_ReallyLR implicit $w0
...
---
name: ctlz_s64
body: |
bb.0:
; CHECK-LABEL: name: ctlz_s64
; CHECK: %res:_(s64) = G_CONSTANT i64 57
; CHECK-NEXT: $x0 = COPY %res(s64)
; CHECK-NEXT: RET_ReallyLR implicit $x0
%a:_(s64) = G_CONSTANT i64 127
%res:_(s64) = G_CTLZ %a
$x0 = COPY %res(s64)
RET_ReallyLR implicit $x0
...
---
name: ctlz_zero_poison_s32
body: |
bb.0:
; CHECK-LABEL: name: ctlz_zero_poison_s32
; CHECK: %res:_(s32) = G_CONSTANT i32 24
; CHECK-NEXT: $w0 = COPY %res(s32)
; CHECK-NEXT: RET_ReallyLR implicit $w0
%a:_(s32) = G_CONSTANT i32 128
%res:_(s32) = G_CTLZ_ZERO_POISON %a
$w0 = COPY %res(s32)
RET_ReallyLR implicit $w0
...
---
name: cttz_s32
body: |
bb.0:
; CHECK-LABEL: name: cttz_s32
; CHECK: %res:_(s32) = G_CONSTANT i32 3
; CHECK-NEXT: $w0 = COPY %res(s32)
; CHECK-NEXT: RET_ReallyLR implicit $w0
%a:_(s32) = G_CONSTANT i32 8
%res:_(s32) = G_CTTZ %a
$w0 = COPY %res(s32)
RET_ReallyLR implicit $w0
...
---
name: cttz_s32_zero
body: |
bb.0:
; CHECK-LABEL: name: cttz_s32_zero
; CHECK: %res:_(s32) = G_CONSTANT i32 32
; CHECK-NEXT: $w0 = COPY %res(s32)
; CHECK-NEXT: RET_ReallyLR implicit $w0
%a:_(s32) = G_CONSTANT i32 0
%res:_(s32) = G_CTTZ %a
$w0 = COPY %res(s32)
RET_ReallyLR implicit $w0
...
---
name: cttz_s64
body: |
bb.0:
; CHECK-LABEL: name: cttz_s64
; CHECK: %res:_(s64) = G_CONSTANT i64 8
; CHECK-NEXT: $x0 = COPY %res(s64)
; CHECK-NEXT: RET_ReallyLR implicit $x0
%a:_(s64) = G_CONSTANT i64 256
%res:_(s64) = G_CTTZ %a
$x0 = COPY %res(s64)
RET_ReallyLR implicit $x0
...
---
name: cttz_zero_poison_s32
body: |
bb.0:
; CHECK-LABEL: name: cttz_zero_poison_s32
; CHECK: %res:_(s32) = G_CONSTANT i32 5
; CHECK-NEXT: $w0 = COPY %res(s32)
; CHECK-NEXT: RET_ReallyLR implicit $w0
%a:_(s32) = G_CONSTANT i32 96
%res:_(s32) = G_CTTZ_ZERO_POISON %a
$w0 = COPY %res(s32)
RET_ReallyLR implicit $w0
...
---
name: ctpop_s32
body: |
bb.0:
; CHECK-LABEL: name: ctpop_s32
; CHECK: %res:_(s32) = G_CONSTANT i32 4
; CHECK-NEXT: $w0 = COPY %res(s32)
; CHECK-NEXT: RET_ReallyLR implicit $w0
%a:_(s32) = G_CONSTANT i32 15
%res:_(s32) = G_CTPOP %a
$w0 = COPY %res(s32)
RET_ReallyLR implicit $w0
...
---
name: ctpop_s32_all_ones
body: |
bb.0:
; CHECK-LABEL: name: ctpop_s32_all_ones
; CHECK: %res:_(s32) = G_CONSTANT i32 32
; CHECK-NEXT: $w0 = COPY %res(s32)
; CHECK-NEXT: RET_ReallyLR implicit $w0
%a:_(s32) = G_CONSTANT i32 -1
%res:_(s32) = G_CTPOP %a
$w0 = COPY %res(s32)
RET_ReallyLR implicit $w0
...
---
name: ctpop_s64
body: |
bb.0:
; CHECK-LABEL: name: ctpop_s64
; CHECK: %res:_(s64) = G_CONSTANT i64 7
; CHECK-NEXT: $x0 = COPY %res(s64)
; CHECK-NEXT: RET_ReallyLR implicit $x0
%a:_(s64) = G_CONSTANT i64 127
%res:_(s64) = G_CTPOP %a
$x0 = COPY %res(s64)
RET_ReallyLR implicit $x0
...
---
name: ctlz_v4s32
body: |
bb.0:
; CHECK-LABEL: name: ctlz_v4s32
; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 31
; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 30
; CHECK-NEXT: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 29
; CHECK-NEXT: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 28
; CHECK-NEXT: %res:_(<4 x s32>) = G_BUILD_VECTOR [[C]](s32), [[C1]](s32), [[C2]](s32), [[C3]](s32)
; CHECK-NEXT: $q0 = COPY %res(<4 x s32>)
; CHECK-NEXT: RET_ReallyLR implicit $q0
%c0:_(s32) = G_CONSTANT i32 1
%c1:_(s32) = G_CONSTANT i32 2
%c2:_(s32) = G_CONSTANT i32 4
%c3:_(s32) = G_CONSTANT i32 8
%v:_(<4 x s32>) = G_BUILD_VECTOR %c0, %c1, %c2, %c3
%res:_(<4 x s32>) = G_CTLZ %v
$q0 = COPY %res(<4 x s32>)
RET_ReallyLR implicit $q0
...
---
name: cttz_v4s32
body: |
bb.0:
; CHECK-LABEL: name: cttz_v4s32
; CHECK: %c0:_(s32) = G_CONSTANT i32 1
; CHECK-NEXT: %c1:_(s32) = G_CONSTANT i32 2
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 3
; CHECK-NEXT: %res:_(<4 x s32>) = G_BUILD_VECTOR [[C]](s32), %c0(s32), %c1(s32), [[C1]](s32)
; CHECK-NEXT: $q0 = COPY %res(<4 x s32>)
; CHECK-NEXT: RET_ReallyLR implicit $q0
%c0:_(s32) = G_CONSTANT i32 1
%c1:_(s32) = G_CONSTANT i32 2
%c2:_(s32) = G_CONSTANT i32 4
%c3:_(s32) = G_CONSTANT i32 8
%v:_(<4 x s32>) = G_BUILD_VECTOR %c0, %c1, %c2, %c3
%res:_(<4 x s32>) = G_CTTZ %v
$q0 = COPY %res(<4 x s32>)
RET_ReallyLR implicit $q0
...
---
name: ctpop_v4s32
body: |
bb.0:
; CHECK-LABEL: name: ctpop_v4s32
; CHECK: %c0:_(s32) = G_CONSTANT i32 1
; CHECK-NEXT: %c1:_(s32) = G_CONSTANT i32 3
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 2
; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 4
; CHECK-NEXT: %res:_(<4 x s32>) = G_BUILD_VECTOR %c0(s32), [[C]](s32), %c1(s32), [[C1]](s32)
; CHECK-NEXT: $q0 = COPY %res(<4 x s32>)
; CHECK-NEXT: RET_ReallyLR implicit $q0
%c0:_(s32) = G_CONSTANT i32 1
%c1:_(s32) = G_CONSTANT i32 3
%c2:_(s32) = G_CONSTANT i32 7
%c3:_(s32) = G_CONSTANT i32 15
%v:_(<4 x s32>) = G_BUILD_VECTOR %c0, %c1, %c2, %c3
%res:_(<4 x s32>) = G_CTPOP %v
$q0 = COPY %res(<4 x s32>)
RET_ReallyLR implicit $q0
...
---
# Negative test: non-constant source should not be folded.
name: ctlz_nonconstant
body: |
bb.0:
liveins: $w0
; CHECK-LABEL: name: ctlz_nonconstant
; CHECK: liveins: $w0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: %a:_(s32) = COPY $w0
; CHECK-NEXT: %res:_(s32) = G_CTLZ %a(s32)
; CHECK-NEXT: $w0 = COPY %res(s32)
; CHECK-NEXT: RET_ReallyLR implicit $w0
%a:_(s32) = COPY $w0
%res:_(s32) = G_CTLZ %a
$w0 = COPY %res(s32)
RET_ReallyLR implicit $w0
...
---
name: abs_s32_pos
body: |
bb.0:
; CHECK-LABEL: name: abs_s32_pos
; CHECK: %a:_(s32) = G_CONSTANT i32 42
; CHECK-NEXT: $w0 = COPY %a(s32)
; CHECK-NEXT: RET_ReallyLR implicit $w0
%a:_(s32) = G_CONSTANT i32 42
%res:_(s32) = G_ABS %a
$w0 = COPY %res(s32)
RET_ReallyLR implicit $w0
...
---
name: abs_s32_neg
body: |
bb.0:
; CHECK-LABEL: name: abs_s32_neg
; CHECK: %res:_(s32) = G_CONSTANT i32 42
; CHECK-NEXT: $w0 = COPY %res(s32)
; CHECK-NEXT: RET_ReallyLR implicit $w0
%a:_(s32) = G_CONSTANT i32 -42
%res:_(s32) = G_ABS %a
$w0 = COPY %res(s32)
RET_ReallyLR implicit $w0
...
---
# abs of INT_MIN stays INT_MIN.
name: abs_s32_int_min
body: |
bb.0:
; CHECK-LABEL: name: abs_s32_int_min
; CHECK: %a:_(s32) = G_CONSTANT i32 -2147483648
; CHECK-NEXT: $w0 = COPY %a(s32)
; CHECK-NEXT: RET_ReallyLR implicit $w0
%a:_(s32) = G_CONSTANT i32 -2147483648
%res:_(s32) = G_ABS %a
$w0 = COPY %res(s32)
RET_ReallyLR implicit $w0
...
---
name: abs_v4s32
body: |
bb.0:
; CHECK-LABEL: name: abs_v4s32
; CHECK: %c1:_(s32) = G_CONSTANT i32 2
; CHECK-NEXT: %c3:_(s32) = G_CONSTANT i32 4
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 3
; CHECK-NEXT: %res:_(<4 x s32>) = G_BUILD_VECTOR [[C]](s32), %c1(s32), [[C1]](s32), %c3(s32)
; CHECK-NEXT: $q0 = COPY %res(<4 x s32>)
; CHECK-NEXT: RET_ReallyLR implicit $q0
%c0:_(s32) = G_CONSTANT i32 -1
%c1:_(s32) = G_CONSTANT i32 2
%c2:_(s32) = G_CONSTANT i32 -3
%c3:_(s32) = G_CONSTANT i32 4
%v:_(<4 x s32>) = G_BUILD_VECTOR %c0, %c1, %c2, %c3
%res:_(<4 x s32>) = G_ABS %v
$q0 = COPY %res(<4 x s32>)
RET_ReallyLR implicit $q0
...
---
name: bswap_s32
body: |
bb.0:
; CHECK-LABEL: name: bswap_s32
; CHECK: %res:_(s32) = G_CONSTANT i32 2018915346
; CHECK-NEXT: $w0 = COPY %res(s32)
; CHECK-NEXT: RET_ReallyLR implicit $w0
%a:_(s32) = G_CONSTANT i32 305419896
%res:_(s32) = G_BSWAP %a
$w0 = COPY %res(s32)
RET_ReallyLR implicit $w0
...
---
name: bswap_s64
body: |
bb.0:
; CHECK-LABEL: name: bswap_s64
; CHECK: %a:_(s64) = G_CONSTANT i64 -1
; CHECK-NEXT: $x0 = COPY %a(s64)
; CHECK-NEXT: RET_ReallyLR implicit $x0
%a:_(s64) = G_CONSTANT i64 -1
%res:_(s64) = G_BSWAP %a
$x0 = COPY %res(s64)
RET_ReallyLR implicit $x0
...
---
name: bswap_v4s32
body: |
bb.0:
; CHECK-LABEL: name: bswap_v4s32
; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16777216
; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 33554432
; CHECK-NEXT: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 67108864
; CHECK-NEXT: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 134217728
; CHECK-NEXT: %res:_(<4 x s32>) = G_BUILD_VECTOR [[C]](s32), [[C1]](s32), [[C2]](s32), [[C3]](s32)
; CHECK-NEXT: $q0 = COPY %res(<4 x s32>)
; CHECK-NEXT: RET_ReallyLR implicit $q0
%c0:_(s32) = G_CONSTANT i32 1
%c1:_(s32) = G_CONSTANT i32 2
%c2:_(s32) = G_CONSTANT i32 4
%c3:_(s32) = G_CONSTANT i32 8
%v:_(<4 x s32>) = G_BUILD_VECTOR %c0, %c1, %c2, %c3
%res:_(<4 x s32>) = G_BSWAP %v
$q0 = COPY %res(<4 x s32>)
RET_ReallyLR implicit $q0
...
---
name: bitreverse_s32
body: |
bb.0:
; CHECK-LABEL: name: bitreverse_s32
; CHECK: %res:_(s32) = G_CONSTANT i32 -2147483648
; CHECK-NEXT: $w0 = COPY %res(s32)
; CHECK-NEXT: RET_ReallyLR implicit $w0
%a:_(s32) = G_CONSTANT i32 1
%res:_(s32) = G_BITREVERSE %a
$w0 = COPY %res(s32)
RET_ReallyLR implicit $w0
...
---
name: bitreverse_s32_all_ones
body: |
bb.0:
; CHECK-LABEL: name: bitreverse_s32_all_ones
; CHECK: %a:_(s32) = G_CONSTANT i32 -1
; CHECK-NEXT: $w0 = COPY %a(s32)
; CHECK-NEXT: RET_ReallyLR implicit $w0
%a:_(s32) = G_CONSTANT i32 -1
%res:_(s32) = G_BITREVERSE %a
$w0 = COPY %res(s32)
RET_ReallyLR implicit $w0
...
---
name: bitreverse_v4s32
body: |
bb.0:
; CHECK-LABEL: name: bitreverse_v4s32
; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -2147483648
; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1073741824
; CHECK-NEXT: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 536870912
; CHECK-NEXT: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 268435456
; CHECK-NEXT: %res:_(<4 x s32>) = G_BUILD_VECTOR [[C]](s32), [[C1]](s32), [[C2]](s32), [[C3]](s32)
; CHECK-NEXT: $q0 = COPY %res(<4 x s32>)
; CHECK-NEXT: RET_ReallyLR implicit $q0
%c0:_(s32) = G_CONSTANT i32 1
%c1:_(s32) = G_CONSTANT i32 2
%c2:_(s32) = G_CONSTANT i32 4
%c3:_(s32) = G_CONSTANT i32 8
%v:_(<4 x s32>) = G_BUILD_VECTOR %c0, %c1, %c2, %c3
%res:_(<4 x s32>) = G_BITREVERSE %v
$q0 = COPY %res(<4 x s32>)
RET_ReallyLR implicit $q0
...
---
# Negative test: non-constant source should not be folded.
name: abs_nonconstant
body: |
bb.0:
liveins: $w0
; CHECK-LABEL: name: abs_nonconstant
; CHECK: liveins: $w0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: %a:_(s32) = COPY $w0
; CHECK-NEXT: %res:_(s32) = G_ABS %a
; CHECK-NEXT: $w0 = COPY %res(s32)
; CHECK-NEXT: RET_ReallyLR implicit $w0
%a:_(s32) = COPY $w0
%res:_(s32) = G_ABS %a
$w0 = COPY %res(s32)
RET_ReallyLR implicit $w0
...