Skip to content

Commit

Permalink
[CVP] Add pre-commit cttz/ctpop tests. NFC.
Browse files Browse the repository at this point in the history
  • Loading branch information
dtcxzyw committed Oct 5, 2023
1 parent 2fab15d commit 253ee85
Showing 1 changed file with 94 additions and 0 deletions.
94 changes: 94 additions & 0 deletions llvm/test/Transforms/CorrelatedValuePropagation/range.ll
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,100 @@ else:
ret i1 %res2
}

define i1 @cttz_fold(i16 %x) {
; CHECK-LABEL: @cttz_fold(
; CHECK-NEXT: [[CMP:%.*]] = icmp ult i16 [[X:%.*]], 256
; CHECK-NEXT: br i1 [[CMP]], label [[IF:%.*]], label [[ELSE:%.*]]
; CHECK: if:
; CHECK-NEXT: [[CTTZ:%.*]] = call i16 @llvm.cttz.i16(i16 [[X]], i1 true)
; CHECK-NEXT: [[RES:%.*]] = icmp uge i16 [[CTTZ]], 8
; CHECK-NEXT: ret i1 [[RES]]
; CHECK: else:
; CHECK-NEXT: ret i1 false
;
%cmp = icmp ult i16 %x, 256
br i1 %cmp, label %if, label %else

if:
%cttz = call i16 @llvm.cttz.i16(i16 %x, i1 true)
%res = icmp uge i16 %cttz, 8
ret i1 %res

else:
ret i1 false
}

define i1 @cttz_nofold(i16 %x) {
; CHECK-LABEL: @cttz_nofold(
; CHECK-NEXT: [[CMP:%.*]] = icmp ult i16 [[X:%.*]], 256
; CHECK-NEXT: br i1 [[CMP]], label [[IF:%.*]], label [[ELSE:%.*]]
; CHECK: if:
; CHECK-NEXT: [[CTTZ:%.*]] = call i16 @llvm.cttz.i16(i16 [[X]], i1 true)
; CHECK-NEXT: [[RES:%.*]] = icmp uge i16 [[CTTZ]], 9
; CHECK-NEXT: ret i1 [[RES]]
; CHECK: else:
; CHECK-NEXT: ret i1 false
;
%cmp = icmp ult i16 %x, 256
br i1 %cmp, label %if, label %else

if:
%cttz = call i16 @llvm.cttz.i16(i16 %x, i1 true)
%res = icmp uge i16 %cttz, 9
ret i1 %res

else:
ret i1 false
}

define i1 @ctpop_fold(i16 %x) {
; CHECK-LABEL: @ctpop_fold(
; CHECK-NEXT: [[CMP:%.*]] = icmp ult i16 [[X:%.*]], 256
; CHECK-NEXT: br i1 [[CMP]], label [[IF:%.*]], label [[ELSE:%.*]]
; CHECK: if:
; CHECK-NEXT: [[CTPOP:%.*]] = call i16 @llvm.ctpop.i16(i16 [[X]])
; CHECK-NEXT: [[RES:%.*]] = icmp ule i16 [[CTPOP]], 8
; CHECK-NEXT: ret i1 [[RES]]
; CHECK: else:
; CHECK-NEXT: ret i1 true
;
%cmp = icmp ult i16 %x, 256
br i1 %cmp, label %if, label %else

if:
%ctpop = call i16 @llvm.ctpop.i16(i16 %x)
%res = icmp ule i16 %ctpop, 8
ret i1 %res

else:
ret i1 true
}

define i1 @ctpop_nofold(i16 %x) {
; CHECK-LABEL: @ctpop_nofold(
; CHECK-NEXT: [[CMP:%.*]] = icmp ult i16 [[X:%.*]], 256
; CHECK-NEXT: br i1 [[CMP]], label [[IF:%.*]], label [[ELSE:%.*]]
; CHECK: if:
; CHECK-NEXT: [[CTPOP:%.*]] = call i16 @llvm.ctpop.i16(i16 [[X]])
; CHECK-NEXT: [[RES:%.*]] = icmp ule i16 [[CTPOP]], 7
; CHECK-NEXT: ret i1 [[RES]]
; CHECK: else:
; CHECK-NEXT: ret i1 true
;
%cmp = icmp ult i16 %x, 256
br i1 %cmp, label %if, label %else

if:
%ctpop = call i16 @llvm.ctpop.i16(i16 %x)
%res = icmp ule i16 %ctpop, 7
ret i1 %res

else:
ret i1 true
}

declare i16 @llvm.ctlz.i16(i16, i1)
declare i16 @llvm.cttz.i16(i16, i1)
declare i16 @llvm.ctpop.i16(i16)
declare i16 @llvm.abs.i16(i16, i1)
declare void @llvm.assume(i1)

0 comments on commit 253ee85

Please sign in to comment.