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
306 lines
9.2 KiB
LLVM
306 lines
9.2 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
|
; RUN: llc -mtriple=aarch64 -mattr=+sve < %s | FileCheck %s
|
|
|
|
; This tests that various ands, sexts, and zexts (and other operations)
|
|
; operating on vscale or the SVE count instructions can be eliminated
|
|
; (via demanded bits) due to their known limited range.
|
|
|
|
; On AArch64 vscale can be at most 16 (for a 2048-bit vector).
|
|
; The counting instructions (sans multiplier) have a value of at most 256
|
|
; (for a 2048-bit vector of i8s).
|
|
|
|
define i32 @vscale_and_elimination() vscale_range(1,16) {
|
|
; CHECK-LABEL: vscale_and_elimination:
|
|
; CHECK: // %bb.0:
|
|
; CHECK-NEXT: rdvl x8, #1
|
|
; CHECK-NEXT: lsr x8, x8, #4
|
|
; CHECK-NEXT: and w9, w8, #0x1c
|
|
; CHECK-NEXT: add w0, w8, w9
|
|
; CHECK-NEXT: ret
|
|
%vscale = call i32 @llvm.vscale.i32()
|
|
%and_redundant = and i32 %vscale, 31
|
|
%and_required = and i32 %vscale, 17179869180
|
|
%result = add i32 %and_redundant, %and_required
|
|
ret i32 %result
|
|
}
|
|
|
|
define i64 @cntb_and_elimination() {
|
|
; CHECK-LABEL: cntb_and_elimination:
|
|
; CHECK: // %bb.0:
|
|
; CHECK-NEXT: cntb x8
|
|
; CHECK-NEXT: and x9, x8, #0x1fc
|
|
; CHECK-NEXT: add x0, x8, x9
|
|
; CHECK-NEXT: ret
|
|
%cntb = call i64 @llvm.aarch64.sve.cntb(i32 31)
|
|
%and_redundant = and i64 %cntb, 511
|
|
%and_required = and i64 %cntb, 17179869180
|
|
%result = add i64 %and_redundant, %and_required
|
|
ret i64 %result
|
|
}
|
|
|
|
define i64 @cnth_and_elimination() {
|
|
; CHECK-LABEL: cnth_and_elimination:
|
|
; CHECK: // %bb.0:
|
|
; CHECK-NEXT: cnth x8
|
|
; CHECK-NEXT: and x9, x8, #0xfc
|
|
; CHECK-NEXT: add x0, x8, x9
|
|
; CHECK-NEXT: ret
|
|
%cnth = call i64 @llvm.aarch64.sve.cnth(i32 31)
|
|
%and_redundant = and i64 %cnth, 1023
|
|
%and_required = and i64 %cnth, 17179869180
|
|
%result = add i64 %and_redundant, %and_required
|
|
ret i64 %result
|
|
}
|
|
|
|
define i64 @cntw_and_elimination() {
|
|
; CHECK-LABEL: cntw_and_elimination:
|
|
; CHECK: // %bb.0:
|
|
; CHECK-NEXT: cntw x8
|
|
; CHECK-NEXT: and x9, x8, #0x7c
|
|
; CHECK-NEXT: add x0, x8, x9
|
|
; CHECK-NEXT: ret
|
|
%cntw = call i64 @llvm.aarch64.sve.cntw(i32 31)
|
|
%and_redundant = and i64 %cntw, 127
|
|
%and_required = and i64 %cntw, 17179869180
|
|
%result = add i64 %and_redundant, %and_required
|
|
ret i64 %result
|
|
}
|
|
|
|
define i64 @cntd_and_elimination() {
|
|
; CHECK-LABEL: cntd_and_elimination:
|
|
; CHECK: // %bb.0:
|
|
; CHECK-NEXT: cntd x8
|
|
; CHECK-NEXT: and x9, x8, #0x3c
|
|
; CHECK-NEXT: add x0, x8, x9
|
|
; CHECK-NEXT: ret
|
|
%cntd = call i64 @llvm.aarch64.sve.cntd(i32 31)
|
|
%and_redundant = and i64 %cntd, 63
|
|
%and_required = and i64 %cntd, 17179869180
|
|
%result = add i64 %and_redundant, %and_required
|
|
ret i64 %result
|
|
}
|
|
|
|
define i64 @cntp_nxv16i1_and_elimination(<vscale x 16 x i1> %p) {
|
|
; CHECK-LABEL: cntp_nxv16i1_and_elimination:
|
|
; CHECK: // %bb.0:
|
|
; CHECK-NEXT: cntp x8, p0, p0.b
|
|
; CHECK-NEXT: and x9, x8, #0x1fc
|
|
; CHECK-NEXT: add x0, x8, x9
|
|
; CHECK-NEXT: ret
|
|
%cntp = tail call i64 @llvm.aarch64.sve.cntp.nxv16i1(<vscale x 16 x i1> %p, <vscale x 16 x i1> %p)
|
|
%and_redundant = and i64 %cntp, 511
|
|
%and_required = and i64 %cntp, 17179869180
|
|
%result = add i64 %and_redundant, %and_required
|
|
ret i64 %result
|
|
}
|
|
|
|
define i64 @cntp_nxv8i1_and_elimination(<vscale x 8 x i1> %p) {
|
|
; CHECK-LABEL: cntp_nxv8i1_and_elimination:
|
|
; CHECK: // %bb.0:
|
|
; CHECK-NEXT: cntp x8, p0, p0.h
|
|
; CHECK-NEXT: and x9, x8, #0xfc
|
|
; CHECK-NEXT: add x0, x8, x9
|
|
; CHECK-NEXT: ret
|
|
%cntp = tail call i64 @llvm.aarch64.sve.cntp.nxv8i1(<vscale x 8 x i1> %p, <vscale x 8 x i1> %p)
|
|
%and_redundant = and i64 %cntp, 1023
|
|
%and_required = and i64 %cntp, 17179869180
|
|
%result = add i64 %and_redundant, %and_required
|
|
ret i64 %result
|
|
}
|
|
|
|
define i64 @cntp_nxv4i1_and_elimination(<vscale x 4 x i1> %p) {
|
|
; CHECK-LABEL: cntp_nxv4i1_and_elimination:
|
|
; CHECK: // %bb.0:
|
|
; CHECK-NEXT: cntp x8, p0, p0.s
|
|
; CHECK-NEXT: and x9, x8, #0x7c
|
|
; CHECK-NEXT: add x0, x8, x9
|
|
; CHECK-NEXT: ret
|
|
%cntp = tail call i64 @llvm.aarch64.sve.cntp.nxv4i1(<vscale x 4 x i1> %p, <vscale x 4 x i1> %p)
|
|
%and_redundant = and i64 %cntp, 127
|
|
%and_required = and i64 %cntp, 17179869180
|
|
%result = add i64 %and_redundant, %and_required
|
|
ret i64 %result
|
|
}
|
|
|
|
define i64 @cntp_nxv2i1_and_elimination(<vscale x 2 x i1> %p) {
|
|
; CHECK-LABEL: cntp_nxv2i1_and_elimination:
|
|
; CHECK: // %bb.0:
|
|
; CHECK-NEXT: cntp x8, p0, p0.d
|
|
; CHECK-NEXT: and x9, x8, #0x3c
|
|
; CHECK-NEXT: add x0, x8, x9
|
|
; CHECK-NEXT: ret
|
|
%cntp = tail call i64 @llvm.aarch64.sve.cntp.nxv2i1(<vscale x 2 x i1> %p, <vscale x 2 x i1> %p)
|
|
%and_redundant = and i64 %cntp, 63
|
|
%and_required = and i64 %cntp, 17179869180
|
|
%result = add i64 %and_redundant, %and_required
|
|
ret i64 %result
|
|
}
|
|
|
|
define i64 @vscale_trunc_zext() vscale_range(1,16) {
|
|
; CHECK-LABEL: vscale_trunc_zext:
|
|
; CHECK: // %bb.0:
|
|
; CHECK-NEXT: rdvl x8, #1
|
|
; CHECK-NEXT: lsr x0, x8, #4
|
|
; CHECK-NEXT: ret
|
|
%vscale = call i32 @llvm.vscale.i32()
|
|
%zext = zext i32 %vscale to i64
|
|
ret i64 %zext
|
|
}
|
|
|
|
define i64 @vscale_trunc_sext() vscale_range(1,16) {
|
|
; CHECK-LABEL: vscale_trunc_sext:
|
|
; CHECK: // %bb.0:
|
|
; CHECK-NEXT: rdvl x8, #1
|
|
; CHECK-NEXT: lsr x0, x8, #4
|
|
; CHECK-NEXT: ret
|
|
%vscale = call i32 @llvm.vscale.i32()
|
|
%sext = sext i32 %vscale to i64
|
|
ret i64 %sext
|
|
}
|
|
|
|
define i64 @count_bytes_trunc_zext() {
|
|
; CHECK-LABEL: count_bytes_trunc_zext:
|
|
; CHECK: // %bb.0:
|
|
; CHECK-NEXT: cntb x0
|
|
; CHECK-NEXT: ret
|
|
%cnt = call i64 @llvm.aarch64.sve.cntb(i32 31)
|
|
%trunc = trunc i64 %cnt to i32
|
|
%zext = zext i32 %trunc to i64
|
|
ret i64 %zext
|
|
}
|
|
|
|
define i64 @count_halfs_trunc_zext() {
|
|
; CHECK-LABEL: count_halfs_trunc_zext:
|
|
; CHECK: // %bb.0:
|
|
; CHECK-NEXT: cnth x0
|
|
; CHECK-NEXT: ret
|
|
%cnt = call i64 @llvm.aarch64.sve.cnth(i32 31)
|
|
%trunc = trunc i64 %cnt to i32
|
|
%zext = zext i32 %trunc to i64
|
|
ret i64 %zext
|
|
}
|
|
|
|
define i64 @count_words_trunc_zext() {
|
|
; CHECK-LABEL: count_words_trunc_zext:
|
|
; CHECK: // %bb.0:
|
|
; CHECK-NEXT: cntw x0
|
|
; CHECK-NEXT: ret
|
|
%cnt = call i64 @llvm.aarch64.sve.cntw(i32 31)
|
|
%trunc = trunc i64 %cnt to i32
|
|
%zext = zext i32 %trunc to i64
|
|
ret i64 %zext
|
|
}
|
|
|
|
define i64 @count_doubles_trunc_zext() {
|
|
; CHECK-LABEL: count_doubles_trunc_zext:
|
|
; CHECK: // %bb.0:
|
|
; CHECK-NEXT: cntd x0
|
|
; CHECK-NEXT: ret
|
|
%cnt = call i64 @llvm.aarch64.sve.cntd(i32 31)
|
|
%trunc = trunc i64 %cnt to i32
|
|
%zext = zext i32 %trunc to i64
|
|
ret i64 %zext
|
|
}
|
|
|
|
define i64 @count_bytes_trunc_sext() {
|
|
; CHECK-LABEL: count_bytes_trunc_sext:
|
|
; CHECK: // %bb.0:
|
|
; CHECK-NEXT: cntb x0
|
|
; CHECK-NEXT: ret
|
|
%cnt = call i64 @llvm.aarch64.sve.cntb(i32 31)
|
|
%trunc = trunc i64 %cnt to i32
|
|
%sext = sext i32 %trunc to i64
|
|
ret i64 %sext
|
|
}
|
|
|
|
define i64 @count_halfs_trunc_sext() {
|
|
; CHECK-LABEL: count_halfs_trunc_sext:
|
|
; CHECK: // %bb.0:
|
|
; CHECK-NEXT: cnth x0
|
|
; CHECK-NEXT: ret
|
|
%cnt = call i64 @llvm.aarch64.sve.cnth(i32 31)
|
|
%trunc = trunc i64 %cnt to i32
|
|
%sext = sext i32 %trunc to i64
|
|
ret i64 %sext
|
|
}
|
|
|
|
define i64 @count_words_trunc_sext() {
|
|
; CHECK-LABEL: count_words_trunc_sext:
|
|
; CHECK: // %bb.0:
|
|
; CHECK-NEXT: cntw x0
|
|
; CHECK-NEXT: ret
|
|
%cnt = call i64 @llvm.aarch64.sve.cntw(i32 31)
|
|
%trunc = trunc i64 %cnt to i32
|
|
%sext = sext i32 %trunc to i64
|
|
ret i64 %sext
|
|
}
|
|
|
|
define i64 @count_doubles_trunc_sext() {
|
|
; CHECK-LABEL: count_doubles_trunc_sext:
|
|
; CHECK: // %bb.0:
|
|
; CHECK-NEXT: cntd x0
|
|
; CHECK-NEXT: ret
|
|
%cnt = call i64 @llvm.aarch64.sve.cntd(i32 31)
|
|
%trunc = trunc i64 %cnt to i32
|
|
%sext = sext i32 %trunc to i64
|
|
ret i64 %sext
|
|
}
|
|
|
|
define i32 @vscale_with_multiplier() vscale_range(1,16) {
|
|
; CHECK-LABEL: vscale_with_multiplier:
|
|
; CHECK: // %bb.0:
|
|
; CHECK-NEXT: rdvl x8, #1
|
|
; CHECK-NEXT: mov w9, #5 // =0x5
|
|
; CHECK-NEXT: lsr x8, x8, #4
|
|
; CHECK-NEXT: mul x8, x8, x9
|
|
; CHECK-NEXT: and w9, w8, #0x3f
|
|
; CHECK-NEXT: add w0, w8, w9
|
|
; CHECK-NEXT: ret
|
|
%vscale = call i32 @llvm.vscale.i32()
|
|
%mul = mul i32 %vscale, 5
|
|
%and_redundant = and i32 %mul, 127
|
|
%and_required = and i32 %mul, 63
|
|
%result = add i32 %and_redundant, %and_required
|
|
ret i32 %result
|
|
}
|
|
|
|
define i32 @vscale_with_negative_multiplier() vscale_range(1,16) {
|
|
; CHECK-LABEL: vscale_with_negative_multiplier:
|
|
; CHECK: // %bb.0:
|
|
; CHECK-NEXT: rdvl x8, #1
|
|
; CHECK-NEXT: mov x9, #-5 // =0xfffffffffffffffb
|
|
; CHECK-NEXT: lsr x8, x8, #4
|
|
; CHECK-NEXT: mul x8, x8, x9
|
|
; CHECK-NEXT: and w9, w8, #0xffffffc0
|
|
; CHECK-NEXT: add w0, w8, w9
|
|
; CHECK-NEXT: ret
|
|
%vscale = call i32 @llvm.vscale.i32()
|
|
%mul = mul i32 %vscale, -5
|
|
%or_redundant = or i32 %mul, 4294967168
|
|
%or_required = and i32 %mul, 4294967232
|
|
%result = add i32 %or_redundant, %or_required
|
|
ret i32 %result
|
|
}
|
|
|
|
define i32 @pow2_vscale_with_negative_multiplier() vscale_range(1,16) {
|
|
; CHECK-LABEL: pow2_vscale_with_negative_multiplier:
|
|
; CHECK: // %bb.0:
|
|
; CHECK-NEXT: cntd x8
|
|
; CHECK-NEXT: neg x9, x8
|
|
; CHECK-NEXT: orr w9, w9, #0xfffffff0
|
|
; CHECK-NEXT: sub w0, w9, w8
|
|
; CHECK-NEXT: ret
|
|
%vscale = call i32 @llvm.vscale.i32()
|
|
%mul = mul i32 %vscale, -2
|
|
%or_redundant = or i32 %mul, 4294967264
|
|
%or_required = or i32 %mul, 4294967280
|
|
%result = add i32 %or_redundant, %or_required
|
|
ret i32 %result
|
|
}
|
|
|
|
declare i32 @llvm.vscale.i32()
|
|
declare i64 @llvm.aarch64.sve.cntb(i32 %pattern)
|
|
declare i64 @llvm.aarch64.sve.cnth(i32 %pattern)
|
|
declare i64 @llvm.aarch64.sve.cntw(i32 %pattern)
|
|
declare i64 @llvm.aarch64.sve.cntd(i32 %pattern)
|