Files
TheRock/compiler/spirv-llvm-translator/test/llvm-intrinsics/add_sub.sat.ll
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

107 lines
3.2 KiB
LLVM

; RUN: llvm-as < %s -o %t.bc
; RUN: llvm-spirv %t.bc -o %t.spv
; RUN: llvm-spirv %t.spv -to-text -o - | FileCheck %s
; RUN: spirv-val %t.spv
; Test checks that saturation addition and substraction llvm intrinsics
; are translated into instruction from OpenCL Extended Instruction Set.
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
target triple = "spir64-unknown-unknown"
; CHECK: ExtInstImport [[ext:[0-9]+]] "OpenCL.std"
; CHECK: Name [[test_uadd:[0-9]+]] "test_uadd"
; CHECK: Name [[test_usub:[0-9]+]] "test_usub"
; CHECK: Name [[test_sadd:[0-9]+]] "test_sadd"
; CHECK: Name [[test_ssub:[0-9]+]] "test_ssub"
; CHECK: Name [[test_vectors:[0-9]+]] "test_vectors"
; CHECK-DAG: TypeInt [[int:[0-9]+]] 32 0
; CHECK-DAG: TypeVoid [[void:[0-9]+]]
; CHECK: TypeVector [[vector:[0-9]+]] [[int]] 4
define spir_func void @test_uadd(i32 %a, i32 %b) {
entry:
%0 = call i32 @llvm.uadd.sat.i32(i32 %a, i32 %b)
ret void
}
; CHECK: Function [[void]] [[test_uadd]]
; CHECK-NEXT: FunctionParameter [[int]] [[lhs:[0-9]+]]
; CHECK-NEXT: FunctionParameter [[int]] [[rhs:[0-9]+]]
; CHECK-EMPTY:
; CHECK-NEXT: Label
; CHECK-NEXT: ExtInst [[int]] {{[0-9]+}} [[ext]] u_add_sat [[lhs]] [[rhs]]
; CHECK-NEXT: Return
define spir_func void @test_usub(i32 %a, i32 %b) {
entry:
%0 = call i32 @llvm.usub.sat.i32(i32 %a, i32 %b)
ret void
}
; CHECK: Function [[void]] [[test_usub]]
; CHECK-NEXT: FunctionParameter [[int]] [[lhs:[0-9]+]]
; CHECK-NEXT: FunctionParameter [[int]] [[rhs:[0-9]+]]
; CHECK-EMPTY:
; CHECK-NEXT: Label
; CHECK-NEXT: ExtInst [[int]] {{[0-9]+}} [[ext]] u_sub_sat [[lhs]] [[rhs]]
; CHECK-NEXT: Return
define spir_func void @test_sadd(i32 %a, i32 %b) {
entry:
%0 = call i32 @llvm.sadd.sat.i32(i32 %a, i32 %b)
ret void
}
; CHECK: Function [[void]] [[test_sadd]]
; CHECK-NEXT: FunctionParameter [[int]] [[lhs:[0-9]+]]
; CHECK-NEXT: FunctionParameter [[int]] [[rhs:[0-9]+]]
; CHECK-EMPTY:
; CHECK-NEXT: Label
; CHECK-NEXT: ExtInst [[int]] {{[0-9]+}} [[ext]] s_add_sat [[lhs]] [[rhs]]
; CHECK-NEXT: Return
define spir_func void @test_ssub(i32 %a, i32 %b) {
entry:
%0 = call i32 @llvm.ssub.sat.i32(i32 %a, i32 %b)
ret void
}
; CHECK: Function [[void]] [[test_ssub]]
; CHECK-NEXT: FunctionParameter [[int]] [[lhs:[0-9]+]]
; CHECK-NEXT: FunctionParameter [[int]] [[rhs:[0-9]+]]
; CHECK-EMPTY:
; CHECK-NEXT: Label
; CHECK-NEXT: ExtInst [[int]] {{[0-9]+}} [[ext]] s_sub_sat [[lhs]] [[rhs]]
; CHECK-NEXT: Return
define spir_func void @test_vectors(<4 x i32> %a, <4 x i32> %b) {
entry:
%0 = call <4 x i32> @llvm.uadd.sat.v4i32(<4 x i32> %a, <4 x i32> %b)
ret void
}
; CHECK: Function [[void]] [[test_vectors]]
; CHECK-NEXT: FunctionParameter [[vector]] [[lhs:[0-9]+]]
; CHECK-NEXT: FunctionParameter [[vector]] [[rhs:[0-9]+]]
; CHECK-EMPTY:
; CHECK-NEXT: Label
; CHECK-NEXT: ExtInst [[vector]] {{[0-9]+}} [[ext]] u_add_sat [[lhs]] [[rhs]]
; CHECK-NEXT: Return
declare i32 @llvm.uadd.sat.i32(i32, i32);
declare i32 @llvm.usub.sat.i32(i32, i32);
declare i32 @llvm.sadd.sat.i32(i32, i32);
declare i32 @llvm.ssub.sat.i32(i32, i32);
declare <4 x i32> @llvm.uadd.sat.v4i32(<4 x i32>, <4 x i32>);
!llvm.module.flags = !{!0}
!opencl.ocl.version = !{!1}
!opencl.spir.version = !{!2}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 1, i32 0}
!2 = !{i32 1, i32 2}