1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
;=========================== begin_copyright_notice ============================
;
; Copyright (C) 2022-2023 Intel Corporation
;
; SPDX-License-Identifier: MIT
;
;============================ end_copyright_notice =============================
; COM: This test verifies whether an SLM global variable uses are updated correctly
; COM: in the following cyclic graph:
; kernelA kernelB
; / \
; f0 f3
; / \\ /
; / \\ /
; f1 f2 /
; \ / /
; foo /
; \ /
; \ /
; \ /
; \ /
; \ /
; bar
; RUN: %opt %use_old_pass_manager% -GenXSLMResolution -march=genx64 -mcpu=Gen9 -S < %s | FileCheck %s
target datalayout = "e-p:64:64-i64:64-n8:16:32"
@SLM_GV = internal addrspace(3) global [4 x i32] undef, align 4 #0
; COM: @SLM_GV access in this node is not supported.
define internal spir_func i32 @bar(i32 addrspace(3)* %arg) #1 {
%arg.ld = load i32, i32 addrspace(3)* %arg, align 4
ret i32 %arg.ld
}
; CHECK: define internal spir_func i32 @foo
; CHECK: %bar.res = call spir_func i32 @bar(i32 addrspace(3)* getelementptr inbounds ([4 x i32], [4 x i32] addrspace(3)* inttoptr (i32 268435456 to [4 x i32] addrspace(3)*), i64 0, i64 1))
define internal spir_func i32 @foo(i32 addrspace(3)* %arg) #1 {
%arg.ld = load i32, i32 addrspace(3)* %arg, align 4
%bar.res = call spir_func i32 @bar(i32 addrspace(3)* getelementptr inbounds ([4 x i32], [4 x i32] addrspace(3)* @SLM_GV, i64 0, i64 1))
%res = add i32 %bar.res, %arg.ld
ret i32 %res
}
; CHECK: define internal spir_func i32 @f1
; CHECK: %gv.p3 = getelementptr inbounds [4 x i32], [4 x i32] addrspace(3)* inttoptr (i32 268435456 to [4 x i32] addrspace(3)*), i64 0, i64 2
define internal spir_func i32 @f1() #1 {
%gv.p3 = getelementptr inbounds [4 x i32], [4 x i32] addrspace(3)* @SLM_GV, i64 0, i64 2
%foo.res = call spir_func i32 @foo(i32 addrspace(3)* %gv.p3)
ret i32 %foo.res
}
; CHECK: define internal spir_func i32 @f2
define internal spir_func i32 @f2() #1 {
; CHECK: %gv.p3.0 = getelementptr inbounds [4 x i32], [4 x i32] addrspace(3)* inttoptr (i32 268435456 to [4 x i32] addrspace(3)*), i64 0, i64
%gv.p3.0 = getelementptr inbounds [4 x i32], [4 x i32] addrspace(3)* @SLM_GV, i64 0, i64 0
%gv.ld.0 = load i32, i32 addrspace(3)* %gv.p3.0, align 4
; CHECK: %gv.p3.3 = getelementptr inbounds [4 x i32], [4 x i32] addrspace(3)* inttoptr (i32 268435456 to [4 x i32] addrspace(3)*), i64 0, i64 3
%gv.p3.3 = getelementptr inbounds [4 x i32], [4 x i32] addrspace(3)* @SLM_GV, i64 0, i64 3
%gv.ld.3 = load i32, i32 addrspace(3)* %gv.p3.3, align 4
%sum = add i32 %gv.ld.0, %gv.ld.3
store i32 %sum, i32 addrspace(3)* %gv.p3.0
%f0.res = call spir_func i32 @f0(i32 addrspace(3)* %gv.p3.0)
%foo.res = call spir_func i32 @foo(i32 addrspace(3)* %gv.p3.3)
%sum.res = add i32 %f0.res, %foo.res
ret i32 %sum.res
}
; CHECK: define internal spir_func i32 @f0
define internal spir_func i32 @f0(i32 addrspace(3)* %arg) #1 {
%arg.ld = load i32, i32 addrspace(3)* %arg, align 4
; CHECK: %gv.p3 = getelementptr inbounds [4 x i32], [4 x i32] addrspace(3)* inttoptr (i32 268435456 to [4 x i32] addrspace(3)*), i64 0, i64 0
%gv.p3 = getelementptr inbounds [4 x i32], [4 x i32] addrspace(3)* @SLM_GV, i64 0, i64 0
%gv.ld = load i32, i32 addrspace(3)* %gv.p3, align 4
%sum = add i32 %arg.ld, %gv.ld
%c = icmp uge i32 %sum, 25
br i1 %c, label %call_f1, label %call_f2
call_f1:
%f1.res = call spir_func i32 @f1()
br label %exit
call_f2:
%f2.res = call spir_func i32 @f2()
br label %exit
exit:
%f0.res = phi i32 [ %f1.res, %call_f1 ], [ %f2.res, %call_f2 ]
ret i32 %f0.res
}
; CHECK: define internal spir_func i32 @f3
; CHECK: %bar.res = call spir_func i32 @bar(i32 addrspace(3)* getelementptr inbounds ([4 x i32], [4 x i32] addrspace(3)* inttoptr (i32 268435456 to [4 x i32] addrspace(3)*), i64 0, i64 0))
define internal spir_func i32 @f3(i32 addrspace(3)* %arg) #1 {
%bar.res = call spir_func i32 @bar(i32 addrspace(3)* getelementptr inbounds ([4 x i32], [4 x i32] addrspace(3)* @SLM_GV, i64 0, i64 0))
%arg.ld = load i32, i32 addrspace(3)* %arg, align 4
%sum = add i32 %bar.res, %arg.ld
ret i32 %sum
}
; CHECK: define dllexport spir_kernel void @kernelA
; CHECK: %res = call spir_func i32 @f0(i32 addrspace(3)* getelementptr inbounds ([4 x i32], [4 x i32] addrspace(3)* inttoptr (i32 268435456 to [4 x i32] addrspace(3)*), i64 0, i64 0))
define dllexport spir_kernel void @kernelA() #2 {
%res = call spir_func i32 @f0(i32 addrspace(3)* getelementptr inbounds ([4 x i32], [4 x i32] addrspace(3)* @SLM_GV, i64 0, i64 0))
ret void
}
; CHECK: define dllexport spir_kernel void @kernelB
; CHECK: %res = call spir_func i32 @f3(i32 addrspace(3)* getelementptr inbounds ([4 x i32], [4 x i32] addrspace(3)* inttoptr (i32 64 to [4 x i32] addrspace(3)*), i64 0, i64 3))
define dllexport spir_kernel void @kernelB() #2 {
%res = call spir_func i32 @f3(i32 addrspace(3)* getelementptr inbounds ([4 x i32], [4 x i32] addrspace(3)* @SLM_GV, i64 0, i64 3))
ret void
}
; CHECK: !{{[[:digit:]]}} = !{void ()* @kernelA, !"kernelA", !{{[[:digit:]]}}, i32 16, !{{[[:digit:]]}}, !{{[[:digit:]]}}, !{{[[:digit:]]}}, i32 0}
; CHECK: !{{[[:digit:]]}} = !{void ()* @kernelB, !"kernelB", !{{[[:digit:]]}}, i32 80, !{{[[:digit:]]}}, !{{[[:digit:]]}}, !{{[[:digit:]]}}, i32 0}
attributes #0 = { "VCGlobalVariable" }
attributes #1 = { noinline nounwind }
attributes #2 = { noinline nounwind "CMGenxMain" }
!genx.kernels = !{!0, !1}
!genx.kernel.internal = !{!4, !5}
; COM: Initial slm size for kernelA is 0
!0 = !{void ()* @kernelA, !"kernelA", !2, i32 0, !2, !2, !3, i32 0}
; COM: Initial slm size for kernelB is 64
!1 = !{void ()* @kernelB, !"kernelB", !2, i32 64, !2, !2, !3, i32 0}
!2 = !{}
!3 = !{!""}
!4 = !{void ()* @kernelA, !2, !2, !2, !2}
!5 = !{void ()* @kernelB, !2, !2, !2, !2}
|