Skip to content

Commit

Permalink
[InstCombine] add tests for ctpop at bitwidth limit; NFC
Browse files Browse the repository at this point in the history
  • Loading branch information
rotateright committed Oct 26, 2020
1 parent 437d755 commit 05f011b
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions llvm/test/Transforms/InstCombine/cmp-intrinsic.ll
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ define <2 x i1> @ctlz_ne_other_v2i32(<2 x i32> %a) {

define i1 @ctlz_eq_other_i32_multiuse(i32 %x, i32* %p) {
; CHECK-LABEL: @ctlz_eq_other_i32_multiuse(
; CHECK-NEXT: [[LZ:%.*]] = tail call i32 @llvm.ctlz.i32(i32 [[X:%.*]], i1 false), !range !0
; CHECK-NEXT: [[LZ:%.*]] = tail call i32 @llvm.ctlz.i32(i32 [[X:%.*]], i1 false), [[RNG0:!range !.*]]
; CHECK-NEXT: store i32 [[LZ]], i32* [[P:%.*]], align 4
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[LZ]], 24
; CHECK-NEXT: ret i1 [[CMP]]
Expand Down Expand Up @@ -169,7 +169,7 @@ define i1 @ctlz_ugt_other_i32(i32 %x) {

define i1 @ctlz_ugt_other_multiuse_i32(i32 %x, i32* %p) {
; CHECK-LABEL: @ctlz_ugt_other_multiuse_i32(
; CHECK-NEXT: [[LZ:%.*]] = tail call i32 @llvm.ctlz.i32(i32 [[X:%.*]], i1 false), !range !0
; CHECK-NEXT: [[LZ:%.*]] = tail call i32 @llvm.ctlz.i32(i32 [[X:%.*]], i1 false), [[RNG0]]
; CHECK-NEXT: store i32 [[LZ]], i32* [[P:%.*]], align 4
; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[X]], 32768
; CHECK-NEXT: ret i1 [[CMP]]
Expand Down Expand Up @@ -329,7 +329,7 @@ define <2 x i1> @cttz_ne_other_v2i32(<2 x i32> %a) {

define i1 @cttz_eq_other_i33_multiuse(i33 %x, i33* %p) {
; CHECK-LABEL: @cttz_eq_other_i33_multiuse(
; CHECK-NEXT: [[TZ:%.*]] = tail call i33 @llvm.cttz.i33(i33 [[X:%.*]], i1 false), !range !1
; CHECK-NEXT: [[TZ:%.*]] = tail call i33 @llvm.cttz.i33(i33 [[X:%.*]], i1 false), [[RNG1:!range !.*]]
; CHECK-NEXT: store i33 [[TZ]], i33* [[P:%.*]], align 4
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i33 [[TZ]], 4
; CHECK-NEXT: ret i1 [[CMP]]
Expand Down Expand Up @@ -375,7 +375,7 @@ define i1 @cttz_ugt_other_i33(i33 %x) {

define i1 @cttz_ugt_other_multiuse_i33(i33 %x, i33* %p) {
; CHECK-LABEL: @cttz_ugt_other_multiuse_i33(
; CHECK-NEXT: [[TZ:%.*]] = tail call i33 @llvm.cttz.i33(i33 [[X:%.*]], i1 false), !range !1
; CHECK-NEXT: [[TZ:%.*]] = tail call i33 @llvm.cttz.i33(i33 [[X:%.*]], i1 false), [[RNG1]]
; CHECK-NEXT: store i33 [[TZ]], i33* [[P:%.*]], align 4
; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i33 [[TZ]], 16
; CHECK-NEXT: ret i1 [[CMP]]
Expand Down Expand Up @@ -491,3 +491,26 @@ define <2 x i1> @ctpop_ne_bitwidth_v2i32(<2 x i32> %x) {
ret <2 x i1> %cmp
}

define i1 @ctpop_ugt_bitwidth_minus_one_i8(i8 %x, i8* %p) {
; CHECK-LABEL: @ctpop_ugt_bitwidth_minus_one_i8(
; CHECK-NEXT: [[POP:%.*]] = tail call i8 @llvm.ctpop.i8(i8 [[X:%.*]]), [[RNG2:!range !.*]]
; CHECK-NEXT: store i8 [[POP]], i8* [[P:%.*]], align 1
; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[POP]], 7
; CHECK-NEXT: ret i1 [[CMP]]
;
%pop = tail call i8 @llvm.ctpop.i8(i8 %x)
store i8 %pop, i8* %p
%cmp = icmp ugt i8 %pop, 7
ret i1 %cmp
}

define <2 x i1> @ctpop_ult_bitwidth_v2i32(<2 x i32> %x) {
; CHECK-LABEL: @ctpop_ult_bitwidth_v2i32(
; CHECK-NEXT: [[POP:%.*]] = tail call <2 x i32> @llvm.ctpop.v2i32(<2 x i32> [[X:%.*]])
; CHECK-NEXT: [[CMP:%.*]] = icmp ult <2 x i32> [[POP]], <i32 32, i32 32>
; CHECK-NEXT: ret <2 x i1> [[CMP]]
;
%pop = tail call <2 x i32> @llvm.ctpop.v2i32(<2 x i32> %x)
%cmp = icmp ult <2 x i32> %pop, <i32 32, i32 32>
ret <2 x i1> %cmp
}

0 comments on commit 05f011b

Please sign in to comment.