|
| 1 | +; This test checks "integrated" invoke_simd support by the sycl-post-link tool: |
| 2 | +; - data flow analysis is able to determine actual target of |
| 3 | +; _Z33__regcall3____builtin_invoke_simd* |
| 4 | +; - functions shared by SYCL and ESIMD callgraphs get cloned and renamed, thus |
| 5 | +; making sure no functions are shared by the callgraphs (currently required by |
| 6 | +; IGC) |
| 7 | + |
| 8 | +; RUN: sycl-post-link -lower-esimd -symbols -split=auto -S %s -o %t.table |
| 9 | +; RUN: FileCheck %s -input-file=%t.table |
| 10 | +; RUN: FileCheck %s -input-file=%t_0.ll --check-prefixes CHECK-IR |
| 11 | +; RUN: FileCheck %s -input-file=%t_0.sym --check-prefixes CHECK-SYM |
| 12 | + |
| 13 | +;------------- Verify generated table file. |
| 14 | +; CHECK: [Code|Properties|Symbols] |
| 15 | +; CHECK: {{.*}}_0.ll|{{.*}}_0.prop|{{.*}}_0.sym |
| 16 | +; CHECK-EMPTY: |
| 17 | + |
| 18 | +;------------- Verify generated symbol file. |
| 19 | +; CHECK-SYM: SYCL_kernel |
| 20 | +; CHECK-SYM: _SIMD_CALLEE |
| 21 | +; CHECK-SYM: ESIMD_kernel |
| 22 | +; CHECK-SYM-EMPTY: |
| 23 | + |
| 24 | +target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64" |
| 25 | +target triple = "spir64-unknown-unknown" |
| 26 | + |
| 27 | +; Function Attrs: convergent |
| 28 | + |
| 29 | +declare dso_local spir_func <4 x float> @__intrin(i64) |
| 30 | + |
| 31 | +define dso_local spir_func <4 x float> @block_read(i64 %addr) noinline { |
| 32 | +;------------- This function is participates in both SYCL and ESIMD callgraphs - |
| 33 | +;------------- check that it is duplicated: |
| 34 | +; CHECK-IR-DAG: define dso_local spir_func <4 x float> @block_read.esimd |
| 35 | + %res = call spir_func <4 x float> @__intrin(i64 %addr) |
| 36 | + ret <4 x float> %res |
| 37 | +} |
| 38 | + |
| 39 | +; Function Attrs: convergent |
| 40 | +declare dso_local spir_func float @_Z33__regcall3____builtin_invoke_simdXX(<4 x float> (float addrspace(4)*, <4 x float>, i32)*, float addrspace(4)*, float, i32) local_unnamed_addr |
| 41 | + |
| 42 | +; Function Attrs: convergent mustprogress noinline norecurse optnone |
| 43 | +define dso_local x86_regcallcc <4 x float> @_SIMD_CALLEE(float addrspace(4)* %A, <4 x float> %non_uni_val, i32 %uni_val) #0 !sycl_explicit_simd !0 !intel_reqd_sub_group_size !0 { |
| 44 | +; Verify that correct attributes are attached to the function: |
| 45 | +; CHECK-IR-DAG: {{.*}} @_SIMD_CALLEE(float addrspace(4)* %A, <4 x float> %non_uni_val, i32 %uni_val) #[[ATTR1:[0-9]+]] |
| 46 | +entry: |
| 47 | + %AA = ptrtoint float addrspace(4)* %A to i64 |
| 48 | + %ii = zext i32 %uni_val to i64 |
| 49 | + %addr = add nuw nsw i64 %ii, %AA |
| 50 | + %data = call spir_func <4 x float> @block_read(i64 %addr) |
| 51 | + %add = fadd <4 x float> %non_uni_val, %data |
| 52 | + ret <4 x float> %add |
| 53 | +} |
| 54 | + |
| 55 | +define internal spir_func float @foo(float addrspace(1)* %ptr) align 2 { |
| 56 | +entry: |
| 57 | +;------------- Typical data flow of the @_SIMD_CALLEE function address in worst |
| 58 | +;------------- case (-O0), when invoke_simd uses function name: |
| 59 | +;------------- float res = invoke_simd(sg, SIMD_CALLEE, uniform{ A }, x, uniform{ y }); |
| 60 | + %f.addr.i = alloca <4 x float> (float addrspace(4)*, <4 x float>, i32)*, align 8 |
| 61 | + %f.addr.ascast.i = addrspacecast <4 x float> (float addrspace(4)*, <4 x float>, i32)** %f.addr.i to <4 x float> (float addrspace(4)*, <4 x float>, i32)* addrspace(4)* |
| 62 | + store <4 x float> (float addrspace(4)*, <4 x float>, i32)* @_SIMD_CALLEE, <4 x float> (float addrspace(4)*, <4 x float>, i32)* addrspace(4)* %f.addr.ascast.i, align 8 |
| 63 | + %FUNC_PTR = load <4 x float> (float addrspace(4)*, <4 x float>, i32)*, <4 x float> (float addrspace(4)*, <4 x float>, i32)* addrspace(4)* %f.addr.ascast.i, align 8 |
| 64 | + |
| 65 | +;------------- Data flow for the parameters of SIMD_CALLEE |
| 66 | + %param_A = addrspacecast float addrspace(1)* %ptr to float addrspace(4)* |
| 67 | + %param_non_uni_val = load float, float addrspace(4)* %param_A, align 4 |
| 68 | + |
| 69 | +;------------- The invoke_simd calls. |
| 70 | + %res1 = call spir_func float @_Z33__regcall3____builtin_invoke_simdXX(<4 x float> (float addrspace(4)*, <4 x float>, i32)* %FUNC_PTR, float addrspace(4)* %param_A, float %param_non_uni_val, i32 10) |
| 71 | +; Verify that %FUNC_PTR is replaced with @_SIMD_CALLEE: |
| 72 | +; CHECK-IR-DAG: %{{.*}} = call spir_func float @_Z33__regcall3____builtin_invoke_simdXX(<4 x float> (float addrspace(4)*, <4 x float>, i32)* @_SIMD_CALLEE, float addrspace(4)* %param_A, float %param_non_uni_val, i32 10) |
| 73 | + ret float %res1 |
| 74 | +} |
| 75 | + |
| 76 | +;------------- SYCL kernel, an entry point |
| 77 | +define dso_local spir_kernel void @SYCL_kernel(float addrspace(1)* %ptr) #2 { |
| 78 | +entry: |
| 79 | + %res1 = call spir_func float @foo(float addrspace(1)* %ptr) |
| 80 | + %ptri = ptrtoint float addrspace(1)* %ptr to i64 |
| 81 | + %vec = call spir_func <4 x float> @block_read(i64 %ptri) |
| 82 | + %res2 = extractelement <4 x float> %vec, i32 0 |
| 83 | + %res = fadd float %res1, %res2 |
| 84 | + store float %res, float addrspace(1)* %ptr |
| 85 | + ret void |
| 86 | +} |
| 87 | + |
| 88 | +;------------- ESIMD kernel, an entry point |
| 89 | +define dso_local spir_kernel void @ESIMD_kernel(float addrspace(1)* %ptr) #3 !sycl_explicit_simd !0 { |
| 90 | +entry: |
| 91 | + %ptr_as4 = addrspacecast float addrspace(1)* %ptr to float addrspace(4)* |
| 92 | + %res = call x86_regcallcc <4 x float> @_SIMD_CALLEE(float addrspace(4)* %ptr_as4, <4 x float> <float 1.0, float 1.0, float 1.0, float 1.0>, i32 0) |
| 93 | + %ptr_x16 = bitcast float addrspace(4)* %ptr_as4 to <4 x float> addrspace(4)* |
| 94 | + store <4 x float> %res, <4 x float> addrspace(4)* %ptr_x16 |
| 95 | + ret void |
| 96 | +} |
| 97 | + |
| 98 | + |
| 99 | +; Check that VCStackCall attribute is added to the invoke_simd target functions: |
| 100 | +attributes #0 = { convergent mustprogress norecurse "sycl-module-id"="invoke_simd.cpp" } |
| 101 | +; CHECK-IR-DAG: attributes #[[ATTR1]] = { {{.*}} "VCStackCall" {{.*}}"sycl-module-id"="invoke_simd.cpp" } |
| 102 | + |
| 103 | +attributes #2 = { "sycl-module-id"="a.cpp" } |
| 104 | +attributes #3 = { "sycl-module-id"="b.cpp" } |
| 105 | + |
| 106 | + |
| 107 | +!0 = !{} |
0 commit comments