| 1 |
; RUN: llvm-as < %s -o %t.bc |
| 2 |
; RUN: llvm-spirv %t.bc -o %t.spv |
| 3 |
; RUN: spirv-val %t.spv |
| 4 |
; RUN: llvm-spirv %t.spv -to-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV |
| 5 |
; RUN: llvm-spirv %t.spv -r -emit-opaque-pointers -o %t.rev.bc |
| 6 |
; RUN: llvm-dis %t.rev.bc -o - | FileCheck %s --check-prefixes=CHECK-LLVM,CHECK-LLVM-OCL |
| 7 |
; RUN: llvm-spirv %t.spv -r -emit-opaque-pointers --spirv-target-env=SPV-IR -o %t.rev.bc |
| 8 |
; RUN: llvm-dis %t.rev.bc -o - | FileCheck %s --check-prefixes=CHECK-LLVM,CHECK-LLVM-SPV |
| 9 |
|
| 10 |
; Check that produced builtin-call-based SPV-IR is recognized by the translator |
| 11 |
; RUN: llvm-spirv %t.rev.bc -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV |
| 12 |
|
| 13 |
; The IR was generated from the following source: |
| 14 |
; #include <CL/sycl.hpp> |
| 15 |
; |
| 16 |
; template <typename T, int N> |
| 17 |
; class sycl_subgr; |
| 18 |
; |
| 19 |
; using namespace cl::sycl; |
| 20 |
; |
| 21 |
; int main() { |
| 22 |
; queue Queue; |
| 23 |
; int X = 8; |
| 24 |
; nd_range<1> NdRange(X, X); |
| 25 |
; buffer<int> buf(X); |
| 26 |
; Queue.submit([&](handler &cgh) { |
| 27 |
; auto acc = buf.template get_access<access::mode::read_write>(cgh); |
| 28 |
; cgh.parallel_for<sycl_subgr<int, 0>>(NdRange, [=](nd_item<1> NdItem) { |
| 29 |
; intel::sub_group SG = NdItem.get_sub_group(); |
| 30 |
; if (X % 2) { |
| 31 |
; acc[0] = SG.get_max_local_range()[0]; |
| 32 |
; } |
| 33 |
; acc[1] = (X % 3) ? 1 : SG.get_max_local_range()[0]; |
| 34 |
; }); |
| 35 |
; }); |
| 36 |
; return 0; |
| 37 |
; } |
| 38 |
; Command line: |
| 39 |
; clang -fsycl -fsycl-device-only -Xclang -fsycl-enable-optimizations tmp.cpp -o tmp.bc |
| 40 |
; llvm-spirv tmp.bc -s -o builtin_vars_opt.ll |
| 41 |
|
| 42 |
; CHECK-SPIRV-DAG: Decorate [[#SG_MaxSize_BI:]] BuiltIn 37 |
| 43 |
; CHECK-SPIRV-DAG: Decorate [[#SG_MaxSize_BI:]] Constant |
| 44 |
; CHECK-SPIRV-DAG: Decorate [[#SG_MaxSize_BI:]] LinkageAttributes "__spirv_BuiltInSubgroupMaxSize" Import |
| 45 |
; |
| 46 |
; CHECK-LLVM-OCL-NOT: @__spirv_BuiltInSubgroupMaxSize |
| 47 |
; CHECK-LLVM-NOT: addrspacecast i32 addrspace(1)* @__spirv_BuiltInSubgroupMaxSize to i32 addrspace(4)* |
| 48 |
; CHECK-LLVM-LABEL: if.then.i |
| 49 |
; CHECK-LLVM-NOT: load |
| 50 |
; CHECK-LLVM-OCL: call spir_func i32 @_Z22get_max_sub_group_sizev() |
| 51 |
; CHECK-LLVM-SPV: call spir_func i32 @_Z30__spirv_BuiltInSubgroupMaxSizev() |
| 52 |
; CHECK-LLVM-LABEL: cond.false.i: |
| 53 |
; CHECK-LLVM-NOT: load |
| 54 |
; CHECK-LLVM-OCL: call spir_func i32 @_Z22get_max_sub_group_sizev() |
| 55 |
; CHECK-LLVM-SPV: call spir_func i32 @_Z30__spirv_BuiltInSubgroupMaxSizev() |
| 56 |
|
| 57 |
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" |
| 58 |
target triple = "spir64-unknown-linux" |
| 59 |
|
| 60 |
%"class._ZTSN2cl4sycl5rangeILi1EEE.cl::sycl::range" = type { %"class._ZTSN2cl4sycl6detail5arrayILi1EEE.cl::sycl::detail::array" } |
| 61 |
%"class._ZTSN2cl4sycl6detail5arrayILi1EEE.cl::sycl::detail::array" = type { [1 x i64] } |
| 62 |
%"class._ZTSN2cl4sycl2idILi1EEE.cl::sycl::id" = type { %"class._ZTSN2cl4sycl6detail5arrayILi1EEE.cl::sycl::detail::array" } |
| 63 |
|
| 64 |
$_ZTS10sycl_subgrIiLi0EE = comdat any |
| 65 |
|
| 66 |
@__spirv_BuiltInSubgroupMaxSize = external dso_local local_unnamed_addr addrspace(1) constant i32, align 4 |
| 67 |
|
| 68 |
|
| 69 |
; Function Attrs: norecurse |
| 70 |
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 #0 comdat !kernel_arg_addr_space !4 !kernel_arg_access_qual !5 !kernel_arg_type !6 !kernel_arg_base_type !6 !kernel_arg_type_qual !7 { |
| 71 |
entry: |
| 72 |
%0 = getelementptr inbounds %"class._ZTSN2cl4sycl2idILi1EEE.cl::sycl::id", %"class._ZTSN2cl4sycl2idILi1EEE.cl::sycl::id"* %_arg_5, i64 0, i32 0, i32 0, i64 0 |
| 73 |
%1 = load i64, i64* %0, align 8 |
| 74 |
%add.ptr.i = getelementptr inbounds i32, i32 addrspace(1)* %_arg_1, i64 %1 |
| 75 |
%2 = and i32 %_arg_, 1 |
| 76 |
%tobool.not.i = icmp eq i32 %2, 0 |
| 77 |
%3 = addrspacecast i32 addrspace(1)* @__spirv_BuiltInSubgroupMaxSize to i32 addrspace(4)* |
| 78 |
br i1 %tobool.not.i, label %if.end.i, label %if.then.i |
| 79 |
|
| 80 |
if.then.i: ; preds = %entry |
| 81 |
%4 = load i32, i32 addrspace(4)* %3, align 4 |
| 82 |
%ptridx.ascast.i14.i = addrspacecast i32 addrspace(1)* %add.ptr.i to i32 addrspace(4)* |
| 83 |
store i32 %4, i32 addrspace(4)* %ptridx.ascast.i14.i, align 4 |
| 84 |
br label %if.end.i |
| 85 |
|
| 86 |
if.end.i: ; preds = %if.then.i, %entry |
| 87 |
%rem3.i = srem i32 %_arg_, 3 |
| 88 |
%tobool4.not.i = icmp eq i32 %rem3.i, 0 |
| 89 |
br i1 %tobool4.not.i, label %cond.false.i, label %"_ZZZ4mainENK3$_0clERN2cl4sycl7handlerEENKUlNS1_7nd_itemILi1EEEE_clES5_.exit" |
| 90 |
|
| 91 |
cond.false.i: ; preds = %if.end.i |
| 92 |
%5 = load i32, i32 addrspace(4)* %3, align 4 |
| 93 |
br label %"_ZZZ4mainENK3$_0clERN2cl4sycl7handlerEENKUlNS1_7nd_itemILi1EEEE_clES5_.exit" |
| 94 |
|
| 95 |
"_ZZZ4mainENK3$_0clERN2cl4sycl7handlerEENKUlNS1_7nd_itemILi1EEEE_clES5_.exit": ; preds = %cond.false.i, %if.end.i |
| 96 |
%cond.i = phi i32 [ %5, %cond.false.i ], [ 1, %if.end.i ] |
| 97 |
%ptridx.i.i = getelementptr inbounds i32, i32 addrspace(1)* %add.ptr.i, i64 1 |
| 98 |
%ptridx.ascast.i.i = addrspacecast i32 addrspace(1)* %ptridx.i.i to i32 addrspace(4)* |
| 99 |
store i32 %cond.i, i32 addrspace(4)* %ptridx.ascast.i.i, align 4 |
| 100 |
ret void |
| 101 |
} |
| 102 |
|
| 103 |
attributes #0 = { norecurse "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "sycl-module-id"="../sycl/test/sub_group/shuffle.cpp" "uniform-work-group-size"="true" "unsafe-fp-math"="false" "use-soft-float"="false" } |
| 104 |
|
| 105 |
!llvm.module.flags = !{!0} |
| 106 |
!opencl.spir.version = !{!1} |
| 107 |
!spirv.Source = !{!2} |
| 108 |
!llvm.ident = !{!3} |
| 109 |
|
| 110 |
!0 = !{i32 1, !"wchar_size", i32 4} |
| 111 |
!1 = !{i32 1, i32 2} |
| 112 |
!2 = !{i32 4, i32 100000} |
| 113 |
!3 = !{!"clang version 12.0.0 (https://github.com/intel/llvm.git e5ea144e480c7b28162a1477b3d462cfc221ff61)"} |
| 114 |
!4 = !{i32 0, i32 1, i32 0, i32 0, i32 0} |
| 115 |
!5 = !{!"none", !"none", !"none", !"none", !"none"} |
| 116 |
!6 = !{!"int", !"int*", !"cl::sycl::range<1>", !"cl::sycl::range<1>", !"cl::sycl::id<1>"} |
| 117 |
!7 = !{!"", !"", !"", !"", !""} |
| 118 |
!8 = !{!9, !9, i64 0} |
| 119 |
!9 = !{!"int", !10, i64 0} |
| 120 |
!10 = !{!"omnipotent char", !11, i64 0} |
| 121 |
!11 = !{!"Simple C++ TBAA"} |