| 1 |
; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV |
| 2 |
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %} |
| 3 |
|
| 4 |
; CHECK-SPIRV: OpSatConvertSToU |
| 5 |
|
| 6 |
;; kernel void testSToU(global int2 *a, global uchar2 *res) { |
| 7 |
;; res[0] = convert_uchar2_sat(*a); |
| 8 |
;; } |
| 9 |
|
| 10 |
define dso_local spir_kernel void @testSToU(ptr addrspace(1) nocapture noundef readonly %a, ptr addrspace(1) nocapture noundef writeonly %res) local_unnamed_addr { |
| 11 |
entry: |
| 12 |
%0 = load <2 x i32>, ptr addrspace(1) %a, align 8 |
| 13 |
%call = call spir_func <2 x i8> @_Z18convert_uchar2_satDv2_i(<2 x i32> noundef %0) |
| 14 |
store <2 x i8> %call, ptr addrspace(1) %res, align 2 |
| 15 |
ret void |
| 16 |
} |
| 17 |
|
| 18 |
declare spir_func <2 x i8> @_Z18convert_uchar2_satDv2_i(<2 x i32> noundef) local_unnamed_addr |
| 19 |
|
| 20 |
; CHECK-SPIRV: OpSatConvertUToS |
| 21 |
|
| 22 |
;; kernel void testUToS(global uint2 *a, global char2 *res) { |
| 23 |
;; res[0] = convert_char2_sat(*a); |
| 24 |
;; } |
| 25 |
|
| 26 |
define dso_local spir_kernel void @testUToS(ptr addrspace(1) nocapture noundef readonly %a, ptr addrspace(1) nocapture noundef writeonly %res) local_unnamed_addr { |
| 27 |
entry: |
| 28 |
%0 = load <2 x i32>, ptr addrspace(1) %a, align 8 |
| 29 |
%call = call spir_func <2 x i8> @_Z17convert_char2_satDv2_j(<2 x i32> noundef %0) |
| 30 |
store <2 x i8> %call, ptr addrspace(1) %res, align 2 |
| 31 |
ret void |
| 32 |
} |
| 33 |
|
| 34 |
declare spir_func <2 x i8> @_Z17convert_char2_satDv2_j(<2 x i32> noundef) local_unnamed_addr |
| 35 |
|
| 36 |
; CHECK-SPIRV: OpConvertUToF |
| 37 |
|
| 38 |
;; kernel void testUToF(global uint2 *a, global float2 *res) { |
| 39 |
;; res[0] = convert_float2_rtz(*a); |
| 40 |
;; } |
| 41 |
|
| 42 |
define dso_local spir_kernel void @testUToF(ptr addrspace(1) nocapture noundef readonly %a, ptr addrspace(1) nocapture noundef writeonly %res) local_unnamed_addr { |
| 43 |
entry: |
| 44 |
%0 = load <2 x i32>, ptr addrspace(1) %a, align 8 |
| 45 |
%call = call spir_func <2 x float> @_Z18convert_float2_rtzDv2_j(<2 x i32> noundef %0) |
| 46 |
store <2 x float> %call, ptr addrspace(1) %res, align 8 |
| 47 |
ret void |
| 48 |
} |
| 49 |
|
| 50 |
declare spir_func <2 x float> @_Z18convert_float2_rtzDv2_j(<2 x i32> noundef) local_unnamed_addr |
| 51 |
|
| 52 |
; CHECK-SPIRV: OpConvertFToU |
| 53 |
|
| 54 |
;; kernel void testFToUSat(global float2 *a, global uint2 *res) { |
| 55 |
;; res[0] = convert_uint2_sat_rtn(*a); |
| 56 |
;; } |
| 57 |
|
| 58 |
define dso_local spir_kernel void @testFToUSat(ptr addrspace(1) nocapture noundef readonly %a, ptr addrspace(1) nocapture noundef writeonly %res) local_unnamed_addr { |
| 59 |
entry: |
| 60 |
%0 = load <2 x float>, ptr addrspace(1) %a, align 8 |
| 61 |
%call = call spir_func <2 x i32> @_Z21convert_uint2_sat_rtnDv2_f(<2 x float> noundef %0) |
| 62 |
store <2 x i32> %call, ptr addrspace(1) %res, align 8 |
| 63 |
ret void |
| 64 |
} |
| 65 |
|
| 66 |
declare spir_func <2 x i32> @_Z21convert_uint2_sat_rtnDv2_f(<2 x float> noundef) local_unnamed_addr |
| 67 |
|
| 68 |
; CHECK-SPIRV: OpSatConvertSToU |
| 69 |
|
| 70 |
;; kernel void testUToUSat(global uchar *a, global uint *res) { |
| 71 |
;; res[0] = convert_uint_sat(*a); |
| 72 |
;; } |
| 73 |
|
| 74 |
define dso_local spir_kernel void @testUToUSat(ptr addrspace(1) nocapture noundef readonly %a, ptr addrspace(1) nocapture noundef writeonly %res) local_unnamed_addr { |
| 75 |
entry: |
| 76 |
%0 = load i8, ptr addrspace(1) %a, align 1 |
| 77 |
%call = call spir_func i32 @_Z16convert_uint_sath(i8 noundef zeroext %0) |
| 78 |
store i32 %call, ptr addrspace(1) %res, align 4 |
| 79 |
ret void |
| 80 |
} |
| 81 |
|
| 82 |
declare spir_func i32 @_Z16convert_uint_sath(i8 noundef zeroext) local_unnamed_addr |
| 83 |
|
| 84 |
; CHECK-SPIRV: OpSatConvertSToU |
| 85 |
|
| 86 |
;; kernel void testUToUSat1(global uint *a, global uchar *res) { |
| 87 |
;; res[0] = convert_uchar_sat(*a); |
| 88 |
;; } |
| 89 |
|
| 90 |
define dso_local spir_kernel void @testUToUSat1(ptr addrspace(1) nocapture noundef readonly %a, ptr addrspace(1) nocapture noundef writeonly %res) local_unnamed_addr { |
| 91 |
entry: |
| 92 |
%0 = load i32, ptr addrspace(1) %a, align 4 |
| 93 |
%call = call spir_func zeroext i8 @_Z17convert_uchar_satj(i32 noundef %0) |
| 94 |
store i8 %call, ptr addrspace(1) %res, align 1 |
| 95 |
ret void |
| 96 |
} |
| 97 |
|
| 98 |
declare spir_func zeroext i8 @_Z17convert_uchar_satj(i32 noundef) local_unnamed_addr |
| 99 |
|
| 100 |
; CHECK-SPIRV: OpConvertFToU |
| 101 |
|
| 102 |
;; kernel void testFToU(global float3 *a, global uint3 *res) { |
| 103 |
;; res[0] = convert_uint3_rtp(*a); |
| 104 |
;; } |
| 105 |
|
| 106 |
define dso_local spir_kernel void @testFToU(ptr addrspace(1) nocapture noundef readonly %a, ptr addrspace(1) nocapture noundef writeonly %res) local_unnamed_addr { |
| 107 |
entry: |
| 108 |
%castToVec4 = bitcast ptr addrspace(1) %a to ptr addrspace(1) |
| 109 |
%loadVec4 = load <4 x float>, ptr addrspace(1) %castToVec4, align 16 |
| 110 |
%extractVec = shufflevector <4 x float> %loadVec4, <4 x float> poison, <3 x i32> <i32 0, i32 1, i32 2> |
| 111 |
%call = call spir_func <3 x i32> @_Z17convert_uint3_rtpDv3_f(<3 x float> noundef %extractVec) |
| 112 |
%extractVec1 = shufflevector <3 x i32> %call, <3 x i32> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 undef> |
| 113 |
%storetmp = bitcast ptr addrspace(1) %res to ptr addrspace(1) |
| 114 |
store <4 x i32> %extractVec1, ptr addrspace(1) %storetmp, align 16 |
| 115 |
ret void |
| 116 |
} |
| 117 |
|
| 118 |
declare spir_func <3 x i32> @_Z17convert_uint3_rtpDv3_f(<3 x float> noundef) local_unnamed_addr |