Skip to content

Commit 3388052

Browse files
committed
address latest PR comments
1 parent 73f26c9 commit 3388052

File tree

3 files changed

+37
-24
lines changed

3 files changed

+37
-24
lines changed

clang/test/CodeGenHLSL/builtins/countbits.hlsl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,76 +3,76 @@
33
// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s
44

55
#ifdef __HLSL_ENABLE_16_BIT
6-
// CHECK: define noundef i16 @
7-
// CHECK: call i16 @llvm.ctpop.i16(
6+
// CHECK-LABEL: test_countbits_ushort
7+
// CHECK: call i16 @llvm.ctpop.i16
88
uint16_t test_countbits_ushort(uint16_t p0)
99
{
1010
return countbits(p0);
1111
}
12-
// CHECK: define noundef <2 x i16> @
12+
// CHECK-LABEL: test_countbits_ushort2
1313
// CHECK: call <2 x i16> @llvm.ctpop.v2i16
1414
uint16_t2 test_countbits_ushort2(uint16_t2 p0)
1515
{
1616
return countbits(p0);
1717
}
18-
// CHECK: define noundef <3 x i16> @
18+
// CHECK-LABEL: test_countbits_ushort3
1919
// CHECK: call <3 x i16> @llvm.ctpop.v3i16
2020
uint16_t3 test_countbits_ushort3(uint16_t3 p0)
2121
{
2222
return countbits(p0);
2323
}
24-
// CHECK: define noundef <4 x i16> @
24+
// CHECK-LABEL: test_countbits_ushort4
2525
// CHECK: call <4 x i16> @llvm.ctpop.v4i16
2626
uint16_t4 test_countbits_ushort4(uint16_t4 p0)
2727
{
2828
return countbits(p0);
2929
}
3030
#endif
3131

32-
// CHECK: define noundef i32 @
33-
// CHECK: call i32 @llvm.ctpop.i32(
32+
// CHECK-LABEL: test_countbits_uint
33+
// CHECK: call i32 @llvm.ctpop.i32
3434
int test_countbits_uint(uint p0)
3535
{
3636
return countbits(p0);
3737
}
38-
// CHECK: define noundef <2 x i32> @
38+
// CHECK-LABEL: test_countbits_uint2
3939
// CHECK: call <2 x i32> @llvm.ctpop.v2i32
4040
uint2 test_countbits_uint2(uint2 p0)
4141
{
4242
return countbits(p0);
4343
}
44-
// CHECK: define noundef <3 x i32> @
44+
// CHECK-LABEL: test_countbits_uint3
4545
// CHECK: call <3 x i32> @llvm.ctpop.v3i32
4646
uint3 test_countbits_uint3(uint3 p0)
4747
{
4848
return countbits(p0);
4949
}
50-
// CHECK: define noundef <4 x i32> @
50+
// CHECK-LABEL: test_countbits_uint4
5151
// CHECK: call <4 x i32> @llvm.ctpop.v4i32
5252
uint4 test_countbits_uint4(uint4 p0)
5353
{
5454
return countbits(p0);
5555
}
5656

57-
// CHECK: define noundef i64 @
58-
// CHECK: call i64 @llvm.ctpop.i64(
57+
// CHECK-LABEL: test_countbits_long
58+
// CHECK: call i64 @llvm.ctpop.i64
5959
uint64_t test_countbits_long(uint64_t p0)
6060
{
6161
return countbits(p0);
6262
}
63-
// CHECK: define noundef <2 x i64> @
63+
// CHECK-LABEL: test_countbits_long2
6464
// CHECK: call <2 x i64> @llvm.ctpop.v2i64
6565
uint64_t2 test_countbits_long2(uint64_t2 p0)
6666
{
6767
return countbits(p0);
6868
}
69-
// CHECK: define noundef <3 x i64> @
69+
// CHECK-LABEL: test_countbits_long3
7070
// CHECK: call <3 x i64> @llvm.ctpop.v3i64
7171
uint64_t3 test_countbits_long3(uint64_t3 p0)
7272
{
7373
return countbits(p0);
7474
}
75-
// CHECK: define noundef <4 x i64> @
75+
// CHECK-LABEL: test_countbits_long4
7676
// CHECK: call <4 x i64> @llvm.ctpop.v4i64
7777
uint64_t4 test_countbits_long4(uint64_t4 p0)
7878
{
Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
// RUN: %clang_cc1 -finclude-default-header
22
// -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only
3-
// -disable-llvm-passes -verify
3+
// -disable-llvm-passes -verify -verify-ignore-unexpected
44

55

66
double test_int_builtin(double p0) {
77
return countbits(p0);
88
// expected-error@-1 {{call to 'countbits' is ambiguous}}
9-
// expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function}}
10-
// expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function}}
11-
// expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function}}
12-
// expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function}}
13-
// expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function}}
14-
// expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function}}
159
}
1610

1711
double2 test_int_builtin_2(double2 p0) {
@@ -24,4 +18,4 @@ double test_int_builtin_3(float p0) {
2418
return __builtin_elementwise_popcount(p0);
2519
// expected-error@-1 {{1st argument must be a vector of integers
2620
// (was 'float')}}
27-
}
21+
}

llvm/test/CodeGen/DirectX/countbits.ll

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: opt -S -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library %s | FileCheck %s
1+
; RUN: opt -S -scalarizer -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library %s | FileCheck %s
22

33
; Make sure dxil operation function calls for countbits are generated for all integer types.
44

@@ -23,6 +23,25 @@ entry:
2323
ret i64 %elt.ctpop
2424
}
2525

26+
define noundef <4 x i32> @countbits_vec4_i32(<4 x i32> noundef %a) {
27+
entry:
28+
; CHECK: [[ee0:%.*]] = extractelement <4 x i32> %a, i64 0
29+
; CHECK: [[ie0:%.*]] = call i32 @dx.op.unary.i32(i32 31, i32 [[ee0]])
30+
; CHECK: [[ee1:%.*]] = extractelement <4 x i32> %a, i64 1
31+
; CHECK: [[ie1:%.*]] = call i32 @dx.op.unary.i32(i32 31, i32 [[ee1]])
32+
; CHECK: [[ee2:%.*]] = extractelement <4 x i32> %a, i64 2
33+
; CHECK: [[ie2:%.*]] = call i32 @dx.op.unary.i32(i32 31, i32 [[ee2]])
34+
; CHECK: [[ee3:%.*]] = extractelement <4 x i32> %a, i64 3
35+
; CHECK: [[ie3:%.*]] = call i32 @dx.op.unary.i32(i32 31, i32 [[ee3]])
36+
; CHECK: insertelement <4 x i32> poison, i32 [[ie0]], i64 0
37+
; CHECK: insertelement <4 x i32> %{{.*}}, i32 [[ie1]], i64 1
38+
; CHECK: insertelement <4 x i32> %{{.*}}, i32 [[ie2]], i64 2
39+
; CHECK: insertelement <4 x i32> %{{.*}}, i32 [[ie3]], i64 3
40+
%2 = call <4 x i32> @llvm.ctpop.v4i32(<4 x i32> %a)
41+
ret <4 x i32> %2
42+
}
43+
2644
declare i16 @llvm.ctpop.i16(i16)
2745
declare i32 @llvm.ctpop.i32(i32)
2846
declare i64 @llvm.ctpop.i64(i64)
47+
declare <4 x i32> @llvm.ctpop.v4i32(<4 x i32>)

0 commit comments

Comments
 (0)