Skip to content

Commit f18efb7

Browse files
committed
[InstCombine] add tests for ctpop of power-of-2; NFC
PR48999
1 parent 9bad7de commit f18efb7

File tree

1 file changed

+24
-2
lines changed
  • llvm/test/Transforms/InstCombine

1 file changed

+24
-2
lines changed

llvm/test/Transforms/InstCombine/ctpop.ll

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ define i1 @test3(i32 %arg) {
4646
; Negative test for when we know nothing
4747
define i1 @test4(i8 %arg) {
4848
; CHECK-LABEL: @test4(
49-
; CHECK-NEXT: [[CNT:%.*]] = call i8 @llvm.ctpop.i8(i8 [[ARG:%.*]]), !range ![[$RANGE:[0-9]+]]
49+
; CHECK-NEXT: [[CNT:%.*]] = call i8 @llvm.ctpop.i8(i8 [[ARG:%.*]]), !range [[RNG0:![0-9]+]]
5050
; CHECK-NEXT: [[RES:%.*]] = icmp eq i8 [[CNT]], 2
5151
; CHECK-NEXT: ret i1 [[RES]]
5252
;
@@ -94,4 +94,26 @@ define i1 @test6(i1 %arg) {
9494
ret i1 %cnt
9595
}
9696

97-
; CHECK: ![[$RANGE]] = !{i8 0, i8 9}
97+
define i8 @mask_one_bit(i8 %x) {
98+
; CHECK-LABEL: @mask_one_bit(
99+
; CHECK-NEXT: [[A:%.*]] = and i8 [[X:%.*]], 16
100+
; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.ctpop.i8(i8 [[A]]), !range [[RNG1:![0-9]+]]
101+
; CHECK-NEXT: ret i8 [[R]]
102+
;
103+
%a = and i8 %x, 16
104+
%r = call i8 @llvm.ctpop.i8(i8 %a)
105+
ret i8 %r
106+
}
107+
108+
define <2 x i32> @mask_one_bit_splat(<2 x i32> %x, <2 x i32>* %p) {
109+
; CHECK-LABEL: @mask_one_bit_splat(
110+
; CHECK-NEXT: [[A:%.*]] = and <2 x i32> [[X:%.*]], <i32 2048, i32 2048>
111+
; CHECK-NEXT: store <2 x i32> [[A]], <2 x i32>* [[P:%.*]], align 8
112+
; CHECK-NEXT: [[R:%.*]] = call <2 x i32> @llvm.ctpop.v2i32(<2 x i32> [[A]])
113+
; CHECK-NEXT: ret <2 x i32> [[R]]
114+
;
115+
%a = and <2 x i32> %x, <i32 2048, i32 2048>
116+
store <2 x i32> %a, <2 x i32>* %p
117+
%r = call <2 x i32> @llvm.ctpop.v2i32(<2 x i32> %a)
118+
ret <2 x i32> %r
119+
}

0 commit comments

Comments
 (0)