1
+ ; This test confirms we don't assert for a single slm_init call
2
+ ; in a basic block with two predecessors.
3
+ ;
4
+ ; RUN: opt < %s -passes=LowerESIMD -S | FileCheck %s
5
+
6
+ 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"
7
+ target triple = "spir64-unknown-unknown"
8
+
9
+ @__spirv_BuiltInGlobalInvocationId = external dso_local local_unnamed_addr addrspace (1 ) constant <3 x i64 >, align 32
10
+
11
+ ; Function Attrs: convergent nounwind
12
+ declare dso_local spir_func void @_Z16__esimd_slm_initj (i32 noundef) local_unnamed_addr
13
+
14
+ ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: readwrite)
15
+ declare void @llvm.assume (i1 noundef)
16
+
17
+ ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
18
+ declare void @llvm.lifetime.start.p0 (i64 immarg, ptr nocapture )
19
+
20
+ ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
21
+ declare void @llvm.lifetime.end.p0 (i64 immarg, ptr nocapture )
22
+
23
+ ; Function Attrs: convergent norecurse nounwind
24
+ define weak_odr dso_local spir_kernel void @foo () local_unnamed_addr #0 !sycl_explicit_simd !0 {
25
+ entry:
26
+ %x.i = alloca i32 , align 4
27
+ %0 = load i64 , ptr addrspace (1 ) @__spirv_BuiltInGlobalInvocationId , align 32
28
+ %cmp.i.i = icmp ult i64 %0 , 2147483648
29
+ tail call void @llvm.assume (i1 %cmp.i.i )
30
+ %tobool.not.i = icmp eq i64 %0 , 0
31
+ br i1 %tobool.not.i , label %foo.exit , label %if.then.i
32
+
33
+ if.then.i: ; preds = %entry
34
+ call void @llvm.lifetime.start.p0 (i64 4 , ptr nonnull %x.i )
35
+ %1 = addrspacecast ptr %x.i to ptr addrspace (4 )
36
+ store volatile i32 0 , ptr addrspace (4 ) %1 , align 4
37
+ call void @llvm.lifetime.end.p0 (i64 4 , ptr nonnull %x.i )
38
+ br label %foo.exit
39
+
40
+ ; CHECK: foo.exit:
41
+ ; CHECK-NEXT: ret void
42
+ foo.exit: ; preds = %entry, %if.then.i
43
+ tail call spir_func void @_Z16__esimd_slm_initj (i32 noundef 100 ) #4
44
+ ret void
45
+ }
46
+
47
+ attributes #0 = { convergent norecurse nounwind "frame-pointer" ="all" "no-trapping-math" ="true" "stack-protector-buffer-size" ="8" "sycl-module-id" ="test.cpp" "sycl-optlevel" ="2" "uniform-work-group-size" ="true" }
48
+
49
+ !0 = !{}
0 commit comments