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

60 lines
2.3 KiB
LLVM

; RUN: opt -S -passes=spirv-prepare-functions -mtriple=spirv64-unknown-unknown < %s | FileCheck %s
; @llvm.bswap.* is replaced with a call to a SPIR-V helper function whose
; body implements the byte-swap with shifts/masks/ors.
define i32 @bswap_i32(i32 %x) {
; CHECK-LABEL: define i32 @bswap_i32(
; CHECK: call i32 @spirv.llvm_bswap_i32(i32 %x)
%r = call i32 @llvm.bswap.i32(i32 %x)
ret i32 %r
}
; @llvm.fshl is wrapped in a generated SPIR-V helper function.
define i32 @fshl_i32(i32 %a, i32 %b, i32 %c) {
; CHECK-LABEL: define i32 @fshl_i32(
; CHECK: call i32 @spirv.llvm_fshl_i32(i32 %a, i32 %b, i32 %c)
%r = call i32 @llvm.fshl.i32(i32 %a, i32 %b, i32 %c)
ret i32 %r
}
; @llvm.fshr is wrapped in a generated SPIR-V helper function.
define i32 @fshr_i32(i32 %a, i32 %b, i32 %c) {
; CHECK-LABEL: define i32 @fshr_i32(
; CHECK: call i32 @spirv.llvm_fshr_i32(i32 %a, i32 %b, i32 %c)
%r = call i32 @llvm.fshr.i32(i32 %a, i32 %b, i32 %c)
ret i32 %r
}
; The bswap helper is materialized with the standard shift/mask/or unrolling.
; CHECK-LABEL: define i32 @spirv.llvm_bswap_i32(i32 %0)
; CHECK-DAG: shl i32 %0, 24
; CHECK-DAG: shl i32 %0, 8
; CHECK-DAG: lshr i32 %0, 8
; CHECK-DAG: lshr i32 %0, 24
; CHECK-DAG: and i32 {{.*}}, 16711680
; CHECK-DAG: and i32 {{.*}}, 65280
; CHECK: ret i32
; The fshl helper is materialized once with the spir_func calling convention
; and computes the rotate body in terms of urem/shl/sub/lshr/or.
; CHECK-LABEL: define spir_func i32 @spirv.llvm_fshl_i32(i32 %0, i32 %1, i32 %2)
; CHECK: %[[#MOD:]] = urem i32 %2, 32
; CHECK: %[[#A:]] = shl i32 %0, %[[#MOD]]
; CHECK: %[[#SUB:]] = sub i32 32, %[[#MOD]]
; CHECK: %[[#B:]] = lshr i32 %1, %[[#SUB]]
; CHECK: %[[#OR:]] = or i32 %[[#A]], %[[#B]]
; CHECK: ret i32 %[[#OR]]
; The fshr helper mirrors fshl but shifts the LSB operand right first.
; CHECK-LABEL: define spir_func i32 @spirv.llvm_fshr_i32(i32 %0, i32 %1, i32 %2)
; CHECK: %[[#MOD:]] = urem i32 %2, 32
; CHECK: %[[#A:]] = lshr i32 %1, %[[#MOD]]
; CHECK: %[[#SUB:]] = sub i32 32, %[[#MOD]]
; CHECK: %[[#B:]] = shl i32 %0, %[[#SUB]]
; CHECK: %[[#OR:]] = or i32 %[[#A]], %[[#B]]
; CHECK: ret i32 %[[#OR]]
declare i32 @llvm.bswap.i32(i32)
declare i32 @llvm.fshl.i32(i32, i32, i32)
declare i32 @llvm.fshr.i32(i32, i32, i32)