1+ ;=========================== begin_copyright_notice ============================
2+ ;
3+ ; Copyright (C) 2025 Intel Corporation
4+ ;
5+ ; SPDX-License-Identifier: MIT
6+ ;
7+ ;============================ end_copyright_notice =============================
8+
9+ ; RUN: %opt_typed_ptrs %use_old_pass_manager% -CMABILegacy -march=genx64 -mcpu=XeHPG -S < %s | FileCheck %s --check-prefixes=CHECK
10+ ; RUN: %opt_opaque_ptrs %use_old_pass_manager% -CMABILegacy -march=genx64 -mcpu=XeHPG -S < %s | FileCheck %s --check-prefixes=CHECK
11+
12+ ; RUN: %opt_new_pm_typed -passes=CMABI -march=genx64 -mcpu=XeHPG -S < %s | FileCheck %s --check-prefixes=CHECK
13+ ; RUN: %opt_new_pm_opaque -passes=CMABI -march=genx64 -mcpu=XeHPG -S < %s | FileCheck %s --check-prefixes=CHECK
14+
15+ target datalayout = "e-p:64:64-i64:64-n8:16:32:64"
16+ target triple = "spir64-unknown-unknown"
17+
18+ ; check that the test did not abort
19+ %test.struct = type <{ i8 addrspace (4 )*, i32 , [4 x i8 ] }>
20+ %struct4 = type { float }
21+
22+ ; CHECK-LABEL: test0
23+ define internal spir_func <3 x i32 > @test0 (%test.struct addrspace (4 )* byval (%test.struct ) %0 ) {
24+ ; CHECK-NOT: alloca
25+ ret <3 x i32 > zeroinitializer
26+ }
27+
28+ ; CHECK-LABEL: test1
29+ define spir_func void @test1 (%struct4* byval (%struct4 ) %s_ptr , float * %f_ptr ) #0 {
30+ ; CHECK: alloca
31+ ; Alloca -> store
32+ %s = load %struct4 , %struct4* %s_ptr
33+ store %struct4 %s , %struct4* %s_ptr
34+ ret void
35+ }
36+
37+ ; CHECK-LABEL: test2
38+ define spir_func void @test2 (%struct4* byval (%struct4 ) %s_ptr , float * %f_ptr ) #0 {
39+ ; CHECK: alloca
40+ ; Alloca -> cast -> store
41+ %s = load %struct4 , %struct4* %s_ptr
42+ %cast1 = bitcast %struct4* %s_ptr to i8*
43+ %cast2 = bitcast i8* %cast1 to i16*
44+ %cast3 = bitcast i16* %cast2 to i32*
45+ %cast4 = bitcast i32* %cast3 to %struct4*
46+ store %struct4 %s , %struct4* %cast4
47+ ret void
48+ }
49+
50+ ; CHECK-LABEL: test3
51+ define spir_func void @test3 (%struct4* byval (%struct4 ) %s_ptr , float * %f_ptr ) #0 {
52+ ; CHECK: alloca
53+ ; Alloca -> GEP -> store
54+ %s = load %struct4 , %struct4* %s_ptr
55+ %load_ptr = getelementptr %struct4 , %struct4* %s_ptr , i32 1 , i32 0
56+ %f = load float , float * %load_ptr
57+ store float %f , float * %load_ptr
58+ ret void
59+ }
60+
61+ ; CHECK-LABEL: test4
62+ define spir_func void @test4 (%struct4* byval (%struct4 ) %s_ptr , float * %f_ptr ) #0 {
63+ ; CHECK-NOT: alloca
64+ ; No Alloca -> GEP, cast, load
65+ %load_ptr = getelementptr %struct4 , %struct4* %s_ptr , i32 1 , i32 0
66+ %f = load float , float * %load_ptr
67+ %cast1 = bitcast %struct4* %s_ptr to i8*
68+ %cast2 = bitcast i8* %cast1 to i16*
69+ %cast3 = bitcast i16* %cast2 to i32*
70+ %cast4 = bitcast i32* %cast3 to %struct4*
71+ %f2 = load %struct4 , %struct4* %cast4
72+ ret void
73+ }
74+
75+ ; CHECK-LABEL: kern
76+ define spir_kernel void @kern (float * %RET , float * %aFOO , i64 %privBase ) #1 {
77+ %str4_ptr = alloca %struct4 , i32 2
78+ %f_value = load float , float * %aFOO
79+ %1 = call spir_func <3 x i32 > @test0 (%test.struct addrspace (4 )* null )
80+ call spir_func void @test1 (%struct4* %str4_ptr , float * %RET )
81+ call spir_func void @test2 (%struct4* %str4_ptr , float * %RET )
82+ call spir_func void @test3 (%struct4* %str4_ptr , float * %RET )
83+ call spir_func void @test4 (%struct4* %str4_ptr , float * %RET )
84+ ret void
85+ }
86+
87+ attributes #0 = { noinline nounwind "CMStackCall" }
88+ attributes #1 = { noinline nounwind "CMGenxMain" "oclrt" ="1" }
89+
90+ !llvm.module.flags = !{!0 }
91+ !opencl.ocl.version = !{!1 }
92+
93+ !0 = !{i32 1 , !"genx.useGlobalMem" , i32 1 }
94+ !1 = !{i32 0 , i32 0 }
95+ !genx.kernels = !{!2 }
96+ !genx.kernel.internal = !{!7 }
97+ !2 = !{void (float *, float *, i64 )* @kern , !"kern" , !3 , i32 0 , !4 , !5 , !6 , i32 0 }
98+ !3 = !{i32 0 , i32 0 , i32 96 }
99+ !4 = !{i32 72 , i32 80 , i32 64 }
100+ !5 = !{i32 0 , i32 0 }
101+ !6 = !{!"" , !"" }
102+ !7 = !{void (float *, float *, i64 )* @kern , !8 , !9 , !10 , null }
103+ !8 = !{i32 0 , i32 0 , i32 0 }
104+ !9 = !{i32 0 , i32 1 , i32 2 }
105+ !10 = !{}
0 commit comments