1 // RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
2 // RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \
3 // RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s
5 #ifdef __HLSL_ENABLE_16_BIT
6 // CHECK-LABEL: test_countbits_ushort
7 // CHECK: [[A:%.*]] = call i16 @llvm.ctpop.i16
8 // CHECK-NEXT: zext i16 [[A]] to i32
9 uint test_countbits_ushort(uint16_t p0)
13 // CHECK-LABEL: test_countbits_short
14 // CHECK: [[A:%.*]] = call i16 @llvm.ctpop.i16
15 // CHECK-NEXT: sext i16 [[A]] to i32
16 uint test_countbits_short(int16_t p0)
20 // CHECK-LABEL: test_countbits_ushort2
21 // CHECK: [[A:%.*]] = call <2 x i16> @llvm.ctpop.v2i16
22 // CHECK-NEXT: zext <2 x i16> [[A]] to <2 x i32>
23 uint2 test_countbits_ushort2(uint16_t2 p0)
27 // CHECK-LABEL: test_countbits_ushort3
28 // CHECK: [[A:%.*]] = call <3 x i16> @llvm.ctpop.v3i16
29 // CHECK-NEXT: zext <3 x i16> [[A]] to <3 x i32>
30 uint3 test_countbits_ushort3(uint16_t3 p0)
34 // CHECK-LABEL: test_countbits_ushort4
35 // CHECK: [[A:%.*]] = call <4 x i16> @llvm.ctpop.v4i16
36 // CHECK-NEXT: zext <4 x i16> [[A]] to <4 x i32>
37 uint4 test_countbits_ushort4(uint16_t4 p0)
43 // CHECK-LABEL: test_countbits_uint
44 // CHECK: call i32 @llvm.ctpop.i32
45 uint test_countbits_uint(uint p0)
49 // CHECK-LABEL: test_countbits_int
50 // CHECK: call i32 @llvm.ctpop.i32
51 uint test_countbits_int(int p0)
55 // CHECK-LABEL: test_countbits_uint2
56 // CHECK: call <2 x i32> @llvm.ctpop.v2i32
57 uint2 test_countbits_uint2(uint2 p0)
61 // CHECK-LABEL: test_countbits_uint3
62 // CHECK: call <3 x i32> @llvm.ctpop.v3i32
63 uint3 test_countbits_uint3(uint3 p0)
67 // CHECK-LABEL: test_countbits_uint4
68 // CHECK: call <4 x i32> @llvm.ctpop.v4i32
69 uint4 test_countbits_uint4(uint4 p0)
74 // CHECK-LABEL: test_countbits_long
75 // CHECK: [[A:%.*]] = call i64 @llvm.ctpop.i64
76 // CHECK-NEXT: trunc i64 [[A]] to i32
77 uint test_countbits_long(uint64_t p0)
81 // CHECK-LABEL: test_countbits_slong
82 // CHECK: [[A:%.*]] = call i64 @llvm.ctpop.i64
83 // CHECK-NEXT: trunc i64 [[A]] to i32
84 uint test_countbits_slong(int64_t p0)
88 // CHECK-LABEL: test_countbits_long2
89 // CHECK: [[A:%.*]] = call <2 x i64> @llvm.ctpop.v2i64
90 // CHECK-NEXT: trunc <2 x i64> [[A]] to <2 x i32>
91 uint2 test_countbits_long2(uint64_t2 p0)
95 // CHECK-LABEL: test_countbits_long3
96 // CHECK: [[A:%.*]] = call <3 x i64> @llvm.ctpop.v3i64
97 // CHECK-NEXT: trunc <3 x i64> [[A]] to <3 x i32>
98 uint3 test_countbits_long3(uint64_t3 p0)
100 return countbits(p0);
102 // CHECK-LABEL: test_countbits_long4
103 // CHECK: [[A:%.*]] = call <4 x i64> @llvm.ctpop.v4i64
104 // CHECK-NEXT: trunc <4 x i64> [[A]] to <4 x i32>
105 uint4 test_countbits_long4(uint64_t4 p0)
107 return countbits(p0);