Files
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

147 lines
6.9 KiB
LLVM

; RUN: opt -S -disable-output -passes="print<demanded-bits>" < %s 2>&1 | FileCheck %s
; CHECK-LABEL: Printing analysis 'Demanded Bits Analysis' for function 'test_basic':
; CHECK-DAG: DemandedBits: 0xff00 for %x = or <2 x i32> %a, zeroinitializer
; CHECK-DAG: DemandedBits: 0xff00 for %y = or <2 x i32> %b, zeroinitializer
; CHECK-DAG: DemandedBits: 0xff00 for %z = or <2 x i32> %x, %y
; CHECK-DAG: DemandedBits: 0xff for %u = lshr <2 x i32> %z, splat (i32 8)
; CHECK-DAG: DemandedBits: 0xff for %r = trunc <2 x i32> %u to <2 x i8>
define <2 x i8> @test_basic(<2 x i32> %a, <2 x i32> %b) {
%x = or <2 x i32> %a, zeroinitializer
%y = or <2 x i32> %b, zeroinitializer
%z = or <2 x i32> %x, %y
%u = lshr <2 x i32> %z, <i32 8, i32 8>
%r = trunc <2 x i32> %u to <2 x i8>
ret <2 x i8> %r
}
; Vector-specific instructions
; CHECK-LABEL: Printing analysis 'Demanded Bits Analysis' for function 'test_extractelement':
; CHECK-DAG: DemandedBits: 0xff for %x = or <2 x i32> %a, zeroinitializer
; CHECK-DAG: DemandedBits: 0xf0 for %z = extractelement <2 x i32> %x, i32 1
; CHECK-DAG: DemandedBits: 0xf for %y = extractelement <2 x i32> %x, i32 0
; CHECK-DAG: DemandedBits: 0xffffffff for %u = and i32 %y, 15
; CHECK-DAG: DemandedBits: 0xffffffff for %v = and i32 %z, 240
; CHECK-DAG: DemandedBits: 0xffffffff for %r = or i32 %u, %v
define i32 @test_extractelement(<2 x i32> %a) {
%x = or <2 x i32> %a, zeroinitializer
%y = extractelement <2 x i32> %x, i32 0
%z = extractelement <2 x i32> %x, i32 1
%u = and i32 %y, 15
%v = and i32 %z, 240
%r = or i32 %u, %v
ret i32 %r
}
; CHECK-LABEL: Printing analysis 'Demanded Bits Analysis' for function 'test_insertelement':
; CHECK-DAG: DemandedBits: 0xff for %x = or i32 %a, 0
; CHECK-DAG: DemandedBits: 0xff for %y = or i32 %b, 0
; CHECK-DAG: DemandedBits: 0xff for %z = insertelement <2 x i32> undef, i32 %x, i32 0
; CHECK-DAG: DemandedBits: 0xff for %u = insertelement <2 x i32> %z, i32 %y, i32 1
; CHECK-DAG: DemandedBits: 0xffffffff for %r = and <2 x i32> %u, <i32 255, i32 127>
define <2 x i32> @test_insertelement(i32 %a, i32 %b) {
%x = or i32 %a, 0
%y = or i32 %b, 0
%z = insertelement <2 x i32> undef, i32 %x, i32 0
%u = insertelement <2 x i32> %z, i32 %y, i32 1
%r = and <2 x i32> %u, <i32 255, i32 127>
ret <2 x i32> %r
}
; CHECK-LABEL: Printing analysis 'Demanded Bits Analysis' for function 'test_shufflevector':
; CHECK-DAG: DemandedBits: 0xff for %x = or <2 x i32> %a, zeroinitializer
; CHECK-DAG: DemandedBits: 0xff for %y = or <2 x i32> %b, zeroinitializer
; CHECK-DAG: DemandedBits: 0xff for %z = shufflevector <2 x i32> %x, <2 x i32> %y, <3 x i32> <i32 0, i32 3, i32 1>
; CHECK-DAG: DemandedBits: 0xffffffff for %r = and <3 x i32> %z, <i32 255, i32 127, i32 0>
define <3 x i32> @test_shufflevector(<2 x i32> %a, <2 x i32> %b) {
%x = or <2 x i32> %a, zeroinitializer
%y = or <2 x i32> %b, zeroinitializer
%z = shufflevector <2 x i32> %x, <2 x i32> %y, <3 x i32> <i32 0, i32 3, i32 1>
%r = and <3 x i32> %z, <i32 255, i32 127, i32 0>
ret <3 x i32> %r
}
; Shifts with splat shift amounts
; CHECK-LABEL: Printing analysis 'Demanded Bits Analysis' for function 'test_shl':
; CHECK-DAG: DemandedBits: 0xf for %x = or <2 x i32> %a, zeroinitializer
; CHECK-DAG: DemandedBits: 0xf0 for %y = shl <2 x i32> %x, splat (i32 4)
; CHECK-DAG: DemandedBits: 0xffffffff for %r = and <2 x i32> %y, splat (i32 240)
define <2 x i32> @test_shl(<2 x i32> %a) {
%x = or <2 x i32> %a, zeroinitializer
%y = shl <2 x i32> %x, <i32 4, i32 4>
%r = and <2 x i32> %y, <i32 240, i32 240>
ret <2 x i32> %r
}
; CHECK-LABEL: Printing analysis 'Demanded Bits Analysis' for function 'test_ashr':
; CHECK-DAG: DemandedBits: 0xf00 for %x = or <2 x i32> %a, zeroinitializer
; CHECK-DAG: DemandedBits: 0xf0 for %y = ashr <2 x i32> %x, splat (i32 4)
; CHECK-DAG: DemandedBits: 0xffffffff for %r = and <2 x i32> %y, splat (i32 240)
define <2 x i32> @test_ashr(<2 x i32> %a) {
%x = or <2 x i32> %a, zeroinitializer
%y = ashr <2 x i32> %x, <i32 4, i32 4>
%r = and <2 x i32> %y, <i32 240, i32 240>
ret <2 x i32> %r
}
; CHECK-LABEL: Printing analysis 'Demanded Bits Analysis' for function 'test_lshr':
; CHECK-DAG: DemandedBits: 0xf00 for %x = or <2 x i32> %a, zeroinitializer
; CHECK-DAG: DemandedBits: 0xf0 for %y = lshr <2 x i32> %x, splat (i32 4)
; CHECK-DAG: DemandedBits: 0xffffffff for %r = and <2 x i32> %y, splat (i32 240)
define <2 x i32> @test_lshr(<2 x i32> %a) {
%x = or <2 x i32> %a, zeroinitializer
%y = lshr <2 x i32> %x, <i32 4, i32 4>
%r = and <2 x i32> %y, <i32 240, i32 240>
ret <2 x i32> %r
}
declare <2 x i32> @llvm.fshl.i32(<2 x i32>, <2 x i32>, <2 x i32>)
declare <2 x i32> @llvm.fshr.i32(<2 x i32>, <2 x i32>, <2 x i32>)
; CHECK-LABEL: Printing analysis 'Demanded Bits Analysis' for function 'test_fshl':
; CHECK-DAG: DemandedBits: 0xf for %x = or <2 x i32> %a, zeroinitializer
; CHECK-DAG: DemandedBits: 0xf0000000 for %y = or <2 x i32> %b, zeroinitializer
; CHECK-DAG: DemandedBits: 0xff for %z = call <2 x i32> @llvm.fshl.v2i32(<2 x i32> %x, <2 x i32> %y, <2 x i32> splat (i32 4))
; CHECK-DAG: DemandedBits: 0xffffffff for %r = and <2 x i32> %z, splat (i32 255)
define <2 x i32> @test_fshl(<2 x i32> %a, <2 x i32> %b) {
%x = or <2 x i32> %a, zeroinitializer
%y = or <2 x i32> %b, zeroinitializer
%z = call <2 x i32> @llvm.fshl.i32(<2 x i32> %x, <2 x i32> %y, <2 x i32> <i32 4, i32 4>)
%r = and <2 x i32> %z, <i32 255, i32 255>
ret <2 x i32> %r
}
; CHECK-LABEL: Printing analysis 'Demanded Bits Analysis' for function 'test_fshr':
; CHECK-DAG: DemandedBits: 0xf for %x = or <2 x i32> %a, zeroinitializer
; CHECK-DAG: DemandedBits: 0xf0000000 for %y = or <2 x i32> %b, zeroinitializer
; CHECK-DAG: DemandedBits: 0xff for %z = call <2 x i32> @llvm.fshr.v2i32(<2 x i32> %x, <2 x i32> %y, <2 x i32> splat (i32 28))
; CHECK-DAG: DemandedBits: 0xffffffff for %r = and <2 x i32> %z, splat (i32 255)
define <2 x i32> @test_fshr(<2 x i32> %a, <2 x i32> %b) {
%x = or <2 x i32> %a, zeroinitializer
%y = or <2 x i32> %b, zeroinitializer
%z = call <2 x i32> @llvm.fshr.i32(<2 x i32> %x, <2 x i32> %y, <2 x i32> <i32 28, i32 28>)
%r = and <2 x i32> %z, <i32 255, i32 255>
ret <2 x i32> %r
}
; FP / Int conversion. These have different input / output types.
; CHECK-LABEL: Printing analysis 'Demanded Bits Analysis' for function 'test_uitofp':
; CHECK-DAG: DemandedBits: 0xffffffff for %x = or <2 x i32> %a, zeroinitializer
define <2 x float> @test_uitofp(<2 x i32> %a) {
%x = or <2 x i32> %a, zeroinitializer
%r = uitofp <2 x i32> %x to <2 x float>
ret <2 x float> %r
}
; CHECK-LABEL: Printing analysis 'Demanded Bits Analysis' for function 'test_fptoui':
; CHECK-DAG: DemandedBits: 0xffffffff for %y = fptoui <2 x float> %x to <2 x i32>
define <2 x i32> @test_fptoui(<2 x float> %a) {
%x = fadd <2 x float> %a, <float 1.0, float 1.0>
%y = fptoui <2 x float> %x to <2 x i32>
%r = and <2 x i32> %y, <i32 255, i32 255>
ret <2 x i32> %y
}