Files
TheRock/compiler/amd-llvm/llvm/test/CodeGen/AArch64/GlobalISel/opt-fold-xor-tbz-tbnz.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

233 lines
6.8 KiB
YAML

# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -mtriple aarch64-unknown-unknown -run-pass=instruction-select -global-isel-abort=1 -verify-machineinstrs %s -o - | FileCheck %s
...
---
name: flip_eq
alignment: 4
legalized: true
regBankSelected: true
body: |
; CHECK-LABEL: name: flip_eq
; CHECK: bb.0:
; CHECK-NEXT: successors: %bb.0(0x40000000), %bb.1(0x40000000)
; CHECK-NEXT: liveins: $x0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: %copy:gpr64all = COPY $x0
; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr32all = COPY %copy.sub_32
; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr32 = COPY [[COPY]]
; CHECK-NEXT: TBNZW [[COPY1]], 3, %bb.1
; CHECK-NEXT: B %bb.0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: bb.1:
; CHECK-NEXT: RET_ReallyLR
bb.0:
successors: %bb.0, %bb.1
liveins: $x0
%copy:gpr(i64) = COPY $x0
; Check bit 3.
%bit:gpr(i64) = G_CONSTANT i64 8
%zero:gpr(i64) = G_CONSTANT i64 0
; 8 has the third bit set.
%fold_cst:gpr(i64) = G_CONSTANT i64 8
; This only has the third bit set if %copy does not. So, to walk through
; this, we want to use a TBNZW on %copy.
%fold_me:gpr(i64) = G_XOR %copy, %fold_cst
%and:gpr(i64) = G_AND %fold_me, %bit
%cmp:gpr(i32) = G_ICMP intpred(eq), %and(i64), %zero
G_BRCOND %cmp, %bb.1
G_BR %bb.0
bb.1:
RET_ReallyLR
...
---
name: flip_ne
alignment: 4
legalized: true
regBankSelected: true
body: |
; CHECK-LABEL: name: flip_ne
; CHECK: bb.0:
; CHECK-NEXT: successors: %bb.0(0x40000000), %bb.1(0x40000000)
; CHECK-NEXT: liveins: $x0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: %copy:gpr64all = COPY $x0
; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr32all = COPY %copy.sub_32
; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr32 = COPY [[COPY]]
; CHECK-NEXT: TBZW [[COPY1]], 3, %bb.1
; CHECK-NEXT: B %bb.0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: bb.1:
; CHECK-NEXT: RET_ReallyLR
bb.0:
successors: %bb.0, %bb.1
liveins: $x0
; Same as eq case, but we should get a TBZW instead.
%copy:gpr(i64) = COPY $x0
%bit:gpr(i64) = G_CONSTANT i64 8
%zero:gpr(i64) = G_CONSTANT i64 0
%fold_cst:gpr(i64) = G_CONSTANT i64 8
%fold_me:gpr(i64) = G_XOR %copy, %fold_cst
%and:gpr(i64) = G_AND %fold_me, %bit
%cmp:gpr(i32) = G_ICMP intpred(ne), %and(i64), %zero
G_BRCOND %cmp, %bb.1
G_BR %bb.0
bb.1:
RET_ReallyLR
...
---
name: dont_flip_eq
alignment: 4
legalized: true
regBankSelected: true
body: |
; CHECK-LABEL: name: dont_flip_eq
; CHECK: bb.0:
; CHECK-NEXT: successors: %bb.0(0x40000000), %bb.1(0x40000000)
; CHECK-NEXT: liveins: $x0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: %copy:gpr64all = COPY $x0
; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr32all = COPY %copy.sub_32
; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr32 = COPY [[COPY]]
; CHECK-NEXT: TBZW [[COPY1]], 3, %bb.1
; CHECK-NEXT: B %bb.0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: bb.1:
; CHECK-NEXT: RET_ReallyLR
bb.0:
successors: %bb.0, %bb.1
liveins: $x0
%copy:gpr(i64) = COPY $x0
; Check bit 3.
%bit:gpr(i64) = G_CONSTANT i64 8
%zero:gpr(i64) = G_CONSTANT i64 0
; 7 does not have the third bit set.
%fold_cst:gpr(i64) = G_CONSTANT i64 7
; This only has the third bit set if %copy does. So, to walk through this,
; we should have a TBZW on %copy.
%fold_me:gpr(i64) = G_XOR %fold_cst, %copy
%and:gpr(i64) = G_AND %fold_me, %bit
%cmp:gpr(i32) = G_ICMP intpred(eq), %and(i64), %zero
G_BRCOND %cmp, %bb.1
G_BR %bb.0
bb.1:
RET_ReallyLR
...
---
name: dont_flip_eq_zext
alignment: 4
legalized: true
regBankSelected: true
tracksRegLiveness: true
body: |
; CHECK-LABEL: name: dont_flip_eq_zext
; CHECK: bb.0:
; CHECK-NEXT: successors: %bb.0(0x40000000), %bb.1(0x40000000)
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr32 = COPY $wzr
; CHECK-NEXT: [[ORNWrr:%[0-9]+]]:gpr32 = ORNWrr $wzr, [[COPY]]
; CHECK-NEXT: [[ORRWrs:%[0-9]+]]:gpr32 = ORRWrs $wzr, [[ORNWrr]], 0
; CHECK-NEXT: [[SUBREG_TO_REG:%[0-9]+]]:gpr64 = SUBREG_TO_REG [[ORRWrs]], %subreg.sub_32
; CHECK-NEXT: TBNZX [[SUBREG_TO_REG]], 63, %bb.1
; CHECK-NEXT: B %bb.0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: bb.1:
; CHECK-NEXT: RET_ReallyLR
bb.0:
successors: %bb.0(0x40000000), %bb.1(0x40000000)
%1:gpr(i32) = G_CONSTANT i32 0
%3:gpr(i32) = G_CONSTANT i32 -1
%4:gpr(i32) = G_XOR %1, %3
%5:gpr(i64) = G_ZEXT %4(i32)
%15:gpr(i64) = G_CONSTANT i64 0
%13:gpr(i32) = G_ICMP intpred(slt), %5(i64), %15
G_BRCOND %13, %bb.1
G_BR %bb.0
bb.1:
RET_ReallyLR
...
---
name: dont_flip_ne
alignment: 4
legalized: true
regBankSelected: true
body: |
; CHECK-LABEL: name: dont_flip_ne
; CHECK: bb.0:
; CHECK-NEXT: successors: %bb.0(0x40000000), %bb.1(0x40000000)
; CHECK-NEXT: liveins: $x0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: %copy:gpr64all = COPY $x0
; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr32all = COPY %copy.sub_32
; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr32 = COPY [[COPY]]
; CHECK-NEXT: TBNZW [[COPY1]], 3, %bb.1
; CHECK-NEXT: B %bb.0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: bb.1:
; CHECK-NEXT: RET_ReallyLR
bb.0:
successors: %bb.0, %bb.1
liveins: $x0
; Same as eq case, but we should get a TBNZW instead.
%copy:gpr(i64) = COPY $x0
%bit:gpr(i64) = G_CONSTANT i64 8
%zero:gpr(i64) = G_CONSTANT i64 0
%fold_cst:gpr(i64) = G_CONSTANT i64 7
%fold_me:gpr(i64) = G_XOR %fold_cst, %copy
%and:gpr(i64) = G_AND %fold_me, %bit
%cmp:gpr(i32) = G_ICMP intpred(ne), %and(i64), %zero
G_BRCOND %cmp, %bb.1
G_BR %bb.0
bb.1:
RET_ReallyLR
...
---
name: xor_chain
alignment: 4
legalized: true
regBankSelected: true
body: |
; CHECK-LABEL: name: xor_chain
; CHECK: bb.0:
; CHECK-NEXT: successors: %bb.0(0x40000000), %bb.1(0x40000000)
; CHECK-NEXT: liveins: $x0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: %copy:gpr64all = COPY $x0
; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr32all = COPY %copy.sub_32
; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr32 = COPY [[COPY]]
; CHECK-NEXT: TBZW [[COPY1]], 3, %bb.1
; CHECK-NEXT: B %bb.0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: bb.1:
; CHECK-NEXT: RET_ReallyLR
bb.0:
successors: %bb.0, %bb.1
liveins: $x0
%copy:gpr(i64) = COPY $x0
%bit:gpr(i64) = G_CONSTANT i64 8
%zero:gpr(i64) = G_CONSTANT i64 0
%fold_cst:gpr(i64) = G_CONSTANT i64 8
; The G_XORs cancel each other out, so we should get a TBZW.
%xor1:gpr(i64) = G_XOR %copy, %fold_cst
%xor2:gpr(i64) = G_XOR %xor1, %fold_cst
%and:gpr(i64) = G_AND %xor2, %bit
%cmp:gpr(i32) = G_ICMP intpred(eq), %and(i64), %zero
G_BRCOND %cmp, %bb.1
G_BR %bb.0
bb.1:
RET_ReallyLR