xref: /llvm-project/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/WaveGetLaneIndex.ll (revision cf3d6fded9eaf1372ccfde1d49dd91df6762d98c)
1; RUN: llc -O0 -verify-machineinstrs -mtriple=spirv-vulkan-unknown %s -o - | FileCheck %s
2; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-vulkan-unknown %s -o - -filetype=obj | spirv-val %}
3
4; This file generated from the following command:
5; clang -cc1 -triple spirv-vulkan-compute -x hlsl -emit-llvm -finclude-default-header -o - - <<EOF
6; [numthreads(1, 1, 1)]
7; void main() {
8;   int idx = WaveGetLaneIndex();
9; }
10; EOF
11
12; CHECK-DAG:                         OpCapability Shader
13; CHECK-DAG:                         OpCapability GroupNonUniform
14; CHECK-DAG:                         OpDecorate %[[#var:]] BuiltIn SubgroupLocalInvocationId
15; CHECK-DAG:            %[[#int:]] = OpTypeInt 32 0
16; CHECK-DAG:           %[[#ptri:]] = OpTypePointer Input %[[#int]]
17; CHECK-DAG:           %[[#ptrf:]] = OpTypePointer Function %[[#int]]
18; CHECK-DAG:             %[[#var]] = OpVariable %[[#ptri]] Input
19
20; CHECK-NOT:                         OpDecorate %[[#var]] LinkageAttributes
21
22
23; ModuleID = '-'
24source_filename = "-"
25target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
26target triple = "spirv-unknown-vulkan-compute"
27
28; Function Attrs: convergent noinline norecurse nounwind optnone
29define internal spir_func void @main() #0 {
30entry:
31  %0 = call token @llvm.experimental.convergence.entry()
32  %idx = alloca i32, align 4
33; CHECK:     %[[#idx:]] = OpVariable %[[#ptrf]] Function
34
35  %1 = call i32 @__hlsl_wave_get_lane_index() [ "convergencectrl"(token %0) ]
36; CHECK:    %[[#tmp:]] = OpLoad %[[#int]] %[[#var]]
37
38  store i32 %1, ptr %idx, align 4
39; CHECK:                 OpStore %[[#idx]] %[[#tmp]]
40
41  ret void
42}
43
44; Function Attrs: norecurse
45define void @main.1() #1 {
46entry:
47  call void @main()
48  ret void
49}
50
51; Function Attrs: convergent
52declare i32 @__hlsl_wave_get_lane_index() #2
53
54; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)
55declare token @llvm.experimental.convergence.entry() #3
56
57attributes #0 = { convergent noinline norecurse nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
58attributes #1 = { norecurse "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
59attributes #2 = { convergent }
60attributes #3 = { convergent nocallback nofree nosync nounwind willreturn memory(none) }
61
62!llvm.module.flags = !{!0, !1}
63!llvm.ident = !{!2}
64
65!0 = !{i32 1, !"wchar_size", i32 4}
66!1 = !{i32 4, !"dx.disable_optimizations", i32 1}
67!2 = !{!"clang version 19.0.0git (/usr/local/google/home/nathangauer/projects/llvm-project/clang bc6fd04b73a195981ee77823cf1382d04ab96c44)"}
68
69