1 // RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -fnative-half-type -triple \
2 // RUN: dxil-pc-shadermodel6.3-compute %s -emit-llvm -disable-llvm-passes -o - | \
3 // RUN: FileCheck %s --check-prefixes=CHECK,CHECK-DXIL
4 // RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -fnative-half-type -triple \
5 // RUN: spirv-pc-vulkan-compute %s -emit-llvm -disable-llvm-passes -o - | \
6 // RUN: FileCheck %s --check-prefixes=CHECK,CHECK-SPIRV
8 // Test basic lowering to runtime function call for int values.
10 // CHECK-LABEL: test_int
11 int test_int(int expr, uint idx) {
12 // CHECK-SPIRV: %[[#entry_tok0:]] = call token @llvm.experimental.convergence.entry()
13 // CHECK-SPIRV: %[[RET:.*]] = call spir_func [[TY:.*]] @llvm.spv.wave.readlane.i32([[TY]] %[[#]], i32 %[[#]]) [ "convergencectrl"(token %[[#entry_tok0]]) ]
14 // CHECK-DXIL: %[[RET:.*]] = call [[TY:.*]] @llvm.dx.wave.readlane.i32([[TY]] %[[#]], i32 %[[#]])
15 // CHECK: ret [[TY]] %[[RET]]
16 return WaveReadLaneAt(expr, idx);
19 // CHECK-DXIL: declare [[TY]] @llvm.dx.wave.readlane.i32([[TY]], i32) #[[#attr:]]
20 // CHECK-SPIRV: declare spir_func [[TY]] @llvm.spv.wave.readlane.i32([[TY]], i32) #[[#attr:]]
22 #ifdef __HLSL_ENABLE_16_BIT
23 // CHECK-LABEL: test_int16
24 int16_t test_int16(int16_t expr, uint idx) {
25 // CHECK-SPIRV: %[[#entry_tok1:]] = call token @llvm.experimental.convergence.entry()
26 // CHECK-SPIRV: %[[RET:.*]] = call spir_func [[TY:.*]] @llvm.spv.wave.readlane.i16([[TY]] %[[#]], i32 %[[#]]) [ "convergencectrl"(token %[[#entry_tok1]]) ]
27 // CHECK-DXIL: %[[RET:.*]] = call [[TY:.*]] @llvm.dx.wave.readlane.i16([[TY]] %[[#]], i32 %[[#]])
28 // CHECK: ret [[TY]] %[[RET]]
29 return WaveReadLaneAt(expr, idx);
32 // CHECK-DXIL: declare [[TY]] @llvm.dx.wave.readlane.i16([[TY]], i32) #[[#attr:]]
33 // CHECK-SPIRV: declare spir_func [[TY]] @llvm.spv.wave.readlane.i16([[TY]], i32) #[[#attr:]]
36 // Test basic lowering to runtime function call with array and float values.
38 // CHECK-LABEL: test_half
39 half test_half(half expr, uint idx) {
40 // CHECK-SPIRV: %[[#entry_tok2:]] = call token @llvm.experimental.convergence.entry()
41 // CHECK-SPIRV: %[[RET:.*]] = call spir_func [[TY:.*]] @llvm.spv.wave.readlane.f16([[TY]] %[[#]], i32 %[[#]]) [ "convergencectrl"(token %[[#entry_tok2]]) ]
42 // CHECK-DXIL: %[[RET:.*]] = call [[TY:.*]] @llvm.dx.wave.readlane.f16([[TY]] %[[#]], i32 %[[#]])
43 // CHECK: ret [[TY]] %[[RET]]
44 return WaveReadLaneAt(expr, idx);
47 // CHECK-DXIL: declare [[TY]] @llvm.dx.wave.readlane.f16([[TY]], i32) #[[#attr:]]
48 // CHECK-SPIRV: declare spir_func [[TY]] @llvm.spv.wave.readlane.f16([[TY]], i32) #[[#attr:]]
50 // CHECK-LABEL: test_double
51 double test_double(double expr, uint idx) {
52 // CHECK-SPIRV: %[[#entry_tok3:]] = call token @llvm.experimental.convergence.entry()
53 // CHECK-SPIRV: %[[RET:.*]] = call spir_func [[TY:.*]] @llvm.spv.wave.readlane.f64([[TY]] %[[#]], i32 %[[#]]) [ "convergencectrl"(token %[[#entry_tok3]]) ]
54 // CHECK-DXIL: %[[RET:.*]] = call [[TY:.*]] @llvm.dx.wave.readlane.f64([[TY]] %[[#]], i32 %[[#]])
55 // CHECK: ret [[TY]] %[[RET]]
56 return WaveReadLaneAt(expr, idx);
59 // CHECK-DXIL: declare [[TY]] @llvm.dx.wave.readlane.f64([[TY]], i32) #[[#attr:]]
60 // CHECK-SPIRV: declare spir_func [[TY]] @llvm.spv.wave.readlane.f64([[TY]], i32) #[[#attr:]]
62 // CHECK-LABEL: test_floatv4
63 float4 test_floatv4(float4 expr, uint idx) {
64 // CHECK-SPIRV: %[[#entry_tok4:]] = call token @llvm.experimental.convergence.entry()
65 // CHECK-SPIRV: %[[RET1:.*]] = call spir_func [[TY1:.*]] @llvm.spv.wave.readlane.v4f32([[TY1]] %[[#]], i32 %[[#]]) [ "convergencectrl"(token %[[#entry_tok4]]) ]
66 // CHECK-DXIL: %[[RET1:.*]] = call [[TY1:.*]] @llvm.dx.wave.readlane.v4f32([[TY1]] %[[#]], i32 %[[#]])
67 // CHECK: ret [[TY1]] %[[RET1]]
68 return WaveReadLaneAt(expr, idx);
71 // CHECK-DXIL: declare [[TY1]] @llvm.dx.wave.readlane.v4f32([[TY1]], i32) #[[#attr]]
72 // CHECK-SPIRV: declare spir_func [[TY1]] @llvm.spv.wave.readlane.v4f32([[TY1]], i32) #[[#attr]]
74 // CHECK: attributes #[[#attr]] = {{{.*}} convergent {{.*}}}