1 ; RUN: llc -O0 -mtriple=spirv64-unknown-linux %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV
3 ;; The IR was generated from the following source:
4 ;; #include <CL/sycl.hpp>
6 ;; template <typename T, int N>
9 ;; using namespace cl::sycl;
14 ;; nd_range<1> NdRange(X, X);
15 ;; buffer<int> buf(X);
16 ;; Queue.submit([&](handler &cgh) {
17 ;; auto acc = buf.template get_access<access::mode::read_write>(cgh);
18 ;; cgh.parallel_for<sycl_subgr<int, 0>>(NdRange, [=](nd_item<1> NdItem) {
19 ;; intel::sub_group SG = NdItem.get_sub_group();
21 ;; acc[0] = SG.get_max_local_range()[0];
23 ;; acc[1] = (X % 3) ? 1 : SG.get_max_local_range()[0];
29 ;; clang -fsycl -fsycl-device-only -Xclang -fsycl-enable-optimizations tmp.cpp -o tmp.bc
30 ;; llvm-spirv tmp.bc -s -o builtin_vars_opt.ll
32 ; CHECK-SPIRV-DAG: OpDecorate %[[#SG_MaxSize_BI:]] BuiltIn SubgroupMaxSize
33 ; CHECK-SPIRV-DAG: OpDecorate %[[#SG_MaxSize_BI:]] Constant
34 ; CHECK-SPIRV-DAG: OpDecorate %[[#SG_MaxSize_BI:]] LinkageAttributes "__spirv_BuiltInSubgroupMaxSize" Import
36 %"class._ZTSN2cl4sycl5rangeILi1EEE.cl::sycl::range" = type { %"class._ZTSN2cl4sycl6detail5arrayILi1EEE.cl::sycl::detail::array" }
37 %"class._ZTSN2cl4sycl6detail5arrayILi1EEE.cl::sycl::detail::array" = type { [1 x i64] }
38 %"class._ZTSN2cl4sycl2idILi1EEE.cl::sycl::id" = type { %"class._ZTSN2cl4sycl6detail5arrayILi1EEE.cl::sycl::detail::array" }
40 $_ZTS10sycl_subgrIiLi0EE = comdat any
42 @__spirv_BuiltInSubgroupMaxSize = external dso_local local_unnamed_addr addrspace(1) constant i32, align 4
45 define weak_odr dso_local spir_kernel void @_ZTS10sycl_subgrIiLi0EE(i32 %_arg_, i32 addrspace(1)* %_arg_1, %"class._ZTSN2cl4sycl5rangeILi1EEE.cl::sycl::range"* byval(%"class._ZTSN2cl4sycl5rangeILi1EEE.cl::sycl::range") align 8 %_arg_3, %"class._ZTSN2cl4sycl5rangeILi1EEE.cl::sycl::range"* byval(%"class._ZTSN2cl4sycl5rangeILi1EEE.cl::sycl::range") align 8 %_arg_4, %"class._ZTSN2cl4sycl2idILi1EEE.cl::sycl::id"* byval(%"class._ZTSN2cl4sycl2idILi1EEE.cl::sycl::id") align 8 %_arg_5) local_unnamed_addr comdat {
47 %0 = getelementptr inbounds %"class._ZTSN2cl4sycl2idILi1EEE.cl::sycl::id", %"class._ZTSN2cl4sycl2idILi1EEE.cl::sycl::id"* %_arg_5, i64 0, i32 0, i32 0, i64 0
48 %1 = load i64, i64* %0, align 8
49 %add.ptr.i = getelementptr inbounds i32, i32 addrspace(1)* %_arg_1, i64 %1
50 %2 = and i32 %_arg_, 1
51 %tobool.not.i = icmp eq i32 %2, 0
52 %3 = addrspacecast i32 addrspace(1)* @__spirv_BuiltInSubgroupMaxSize to i32 addrspace(4)*
53 br i1 %tobool.not.i, label %if.end.i, label %if.then.i
55 if.then.i: ; preds = %entry
56 %4 = load i32, i32 addrspace(4)* %3, align 4
57 %ptridx.ascast.i14.i = addrspacecast i32 addrspace(1)* %add.ptr.i to i32 addrspace(4)*
58 store i32 %4, i32 addrspace(4)* %ptridx.ascast.i14.i, align 4
61 if.end.i: ; preds = %if.then.i, %entry
62 %rem3.i = srem i32 %_arg_, 3
63 %tobool4.not.i = icmp eq i32 %rem3.i, 0
64 br i1 %tobool4.not.i, label %cond.false.i, label %"_ZZZ4mainENK3$_0clERN2cl4sycl7handlerEENKUlNS1_7nd_itemILi1EEEE_clES5_.exit"
66 cond.false.i: ; preds = %if.end.i
67 %5 = load i32, i32 addrspace(4)* %3, align 4
68 br label %"_ZZZ4mainENK3$_0clERN2cl4sycl7handlerEENKUlNS1_7nd_itemILi1EEEE_clES5_.exit"
70 "_ZZZ4mainENK3$_0clERN2cl4sycl7handlerEENKUlNS1_7nd_itemILi1EEEE_clES5_.exit": ; preds = %cond.false.i, %if.end.i
71 %cond.i = phi i32 [ %5, %cond.false.i ], [ 1, %if.end.i ]
72 %ptridx.i.i = getelementptr inbounds i32, i32 addrspace(1)* %add.ptr.i, i64 1
73 %ptridx.ascast.i.i = addrspacecast i32 addrspace(1)* %ptridx.i.i to i32 addrspace(4)*
74 store i32 %cond.i, i32 addrspace(4)* %ptridx.ascast.i.i, align 4