Debian Codegraph @

clang/test/CodeGenHLSL/builtins/firstbitlow.hlsl

raw
1 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
2 // RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type -fnative-int16-type \
3 // RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s -DTARGET=dx
4 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
5 // RUN: spirv-unknown-vulkan-compute %s -fnative-half-type -fnative-int16-type \
6 // RUN: -emit-llvm -disable-llvm-passes \
7 // RUN: -o - | FileCheck %s -DTARGET=spv
8
9 #ifdef __HLSL_ENABLE_16_BIT
10 // CHECK-LABEL: test_firstbitlow_ushort
11 // CHECK: call i32 @llvm.[[TARGET]].firstbitlow.i16
12 uint test_firstbitlow_ushort(uint16_t p0) {
13 return firstbitlow(p0);
14 }
15
16 // CHECK-LABEL: test_firstbitlow_ushort2
17 // CHECK: call <2 x i32> @llvm.[[TARGET]].firstbitlow.v2i16
18 uint2 test_firstbitlow_ushort2(uint16_t2 p0) {
19 return firstbitlow(p0);
20 }
21
22 // CHECK-LABEL: test_firstbitlow_ushort3
23 // CHECK: call <3 x i32> @llvm.[[TARGET]].firstbitlow.v3i16
24 uint3 test_firstbitlow_ushort3(uint16_t3 p0) {
25 return firstbitlow(p0);
26 }
27
28 // CHECK-LABEL: test_firstbitlow_ushort4
29 // CHECK: call <4 x i32> @llvm.[[TARGET]].firstbitlow.v4i16
30 uint4 test_firstbitlow_ushort4(uint16_t4 p0) {
31 return firstbitlow(p0);
32 }
33
34 // CHECK-LABEL: test_firstbitlow_short
35 // CHECK: call i32 @llvm.[[TARGET]].firstbitlow.i16
36 uint test_firstbitlow_short(int16_t p0) {
37 return firstbitlow(p0);
38 }
39
40 // CHECK-LABEL: test_firstbitlow_short2
41 // CHECK: call <2 x i32> @llvm.[[TARGET]].firstbitlow.v2i16
42 uint2 test_firstbitlow_short2(int16_t2 p0) {
43 return firstbitlow(p0);
44 }
45
46 // CHECK-LABEL: test_firstbitlow_short3
47 // CHECK: call <3 x i32> @llvm.[[TARGET]].firstbitlow.v3i16
48 uint3 test_firstbitlow_short3(int16_t3 p0) {
49 return firstbitlow(p0);
50 }
51
52 // CHECK-LABEL: test_firstbitlow_short4
53 // CHECK: call <4 x i32> @llvm.[[TARGET]].firstbitlow.v4i16
54 uint4 test_firstbitlow_short4(int16_t4 p0) {
55 return firstbitlow(p0);
56 }
57 #endif // __HLSL_ENABLE_16_BIT
58
59 // CHECK-LABEL: test_firstbitlow_uint
60 // CHECK: call i32 @llvm.[[TARGET]].firstbitlow.i32
61 uint test_firstbitlow_uint(uint p0) {
62 return firstbitlow(p0);
63 }
64
65 // CHECK-LABEL: test_firstbitlow_uint2
66 // CHECK: call <2 x i32> @llvm.[[TARGET]].firstbitlow.v2i32
67 uint2 test_firstbitlow_uint2(uint2 p0) {
68 return firstbitlow(p0);
69 }
70
71 // CHECK-LABEL: test_firstbitlow_uint3
72 // CHECK: call <3 x i32> @llvm.[[TARGET]].firstbitlow.v3i32
73 uint3 test_firstbitlow_uint3(uint3 p0) {
74 return firstbitlow(p0);
75 }
76
77 // CHECK-LABEL: test_firstbitlow_uint4
78 // CHECK: call <4 x i32> @llvm.[[TARGET]].firstbitlow.v4i32
79 uint4 test_firstbitlow_uint4(uint4 p0) {
80 return firstbitlow(p0);
81 }
82
83 // CHECK-LABEL: test_firstbitlow_ulong
84 // CHECK: call i32 @llvm.[[TARGET]].firstbitlow.i64
85 uint test_firstbitlow_ulong(uint64_t p0) {
86 return firstbitlow(p0);
87 }
88
89 // CHECK-LABEL: test_firstbitlow_ulong2
90 // CHECK: call <2 x i32> @llvm.[[TARGET]].firstbitlow.v2i64
91 uint2 test_firstbitlow_ulong2(uint64_t2 p0) {
92 return firstbitlow(p0);
93 }
94
95 // CHECK-LABEL: test_firstbitlow_ulong3
96 // CHECK: call <3 x i32> @llvm.[[TARGET]].firstbitlow.v3i64
97 uint3 test_firstbitlow_ulong3(uint64_t3 p0) {
98 return firstbitlow(p0);
99 }
100
101 // CHECK-LABEL: test_firstbitlow_ulong4
102 // CHECK: call <4 x i32> @llvm.[[TARGET]].firstbitlow.v4i64
103 uint4 test_firstbitlow_ulong4(uint64_t4 p0) {
104 return firstbitlow(p0);
105 }
106
107 // CHECK-LABEL: test_firstbitlow_int
108 // CHECK: call i32 @llvm.[[TARGET]].firstbitlow.i32
109 uint test_firstbitlow_int(int p0) {
110 return firstbitlow(p0);
111 }
112
113 // CHECK-LABEL: test_firstbitlow_int2
114 // CHECK: call <2 x i32> @llvm.[[TARGET]].firstbitlow.v2i32
115 uint2 test_firstbitlow_int2(int2 p0) {
116 return firstbitlow(p0);
117 }
118
119 // CHECK-LABEL: test_firstbitlow_int3
120 // CHECK: call <3 x i32> @llvm.[[TARGET]].firstbitlow.v3i32
121 uint3 test_firstbitlow_int3(int3 p0) {
122 return firstbitlow(p0);
123 }
124
125 // CHECK-LABEL: test_firstbitlow_int4
126 // CHECK: call <4 x i32> @llvm.[[TARGET]].firstbitlow.v4i32
127 uint4 test_firstbitlow_int4(int4 p0) {
128 return firstbitlow(p0);
129 }
130
131 // CHECK-LABEL: test_firstbitlow_long
132 // CHECK: call i32 @llvm.[[TARGET]].firstbitlow.i64
133 uint test_firstbitlow_long(int64_t p0) {
134 return firstbitlow(p0);
135 }
136
137 // CHECK-LABEL: test_firstbitlow_long2
138 // CHECK: call <2 x i32> @llvm.[[TARGET]].firstbitlow.v2i64
139 uint2 test_firstbitlow_long2(int64_t2 p0) {
140 return firstbitlow(p0);
141 }
142
143 // CHECK-LABEL: test_firstbitlow_long3
144 // CHECK: call <3 x i32> @llvm.[[TARGET]].firstbitlow.v3i64
145 uint3 test_firstbitlow_long3(int64_t3 p0) {
146 return firstbitlow(p0);
147 }
148
149 // CHECK-LABEL: test_firstbitlow_long4
150 // CHECK: call <4 x i32> @llvm.[[TARGET]].firstbitlow.v4i64
151 uint4 test_firstbitlow_long4(int64_t4 p0) {
152 return firstbitlow(p0);
153 }
154
155 // CHECK-LABEL: test_firstbitlow_upcast
156 // CHECK: [[FBL:%.*]] = call <4 x i32> @llvm.[[TARGET]].firstbitlow.v4i32(<4 x i32> %{{.*}})
157 // CHECK: [[CONV:%.*]] = zext <4 x i32> [[FBL]] to <4 x i64>
158 // CHECK: ret <4 x i64> [[CONV]]
159 uint64_t4 test_firstbitlow_upcast(uint4 p0) {
160 return firstbitlow(p0);
161 }