mirror of
https://github.com/RPCSX/llvm.git
synced 2025-01-25 13:45:34 +00:00
[InstCombine] Add test cases to show missed opportunities to remove compare instructions after cttz/ctlz/ctpop where some bits of the input is known.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304224 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
79654737d7
commit
7aecbf8e99
@ -52,3 +52,19 @@ define i1 @test4(i8 %arg) {
|
||||
%res = icmp eq i8 %cnt, 2
|
||||
ret i1 %res
|
||||
}
|
||||
|
||||
; Test when the number of possible known bits isn't one less than a power of 2
|
||||
; and the compare value is greater but less than the next power of 2.
|
||||
; TODO: The icmp is unnecessary given the known bits of the input.
|
||||
define i1 @test5(i32 %arg) {
|
||||
; CHECK-LABEL: @test5(
|
||||
; CHECK-NEXT: [[AND:%.*]] = and i32 [[ARG:%.*]], 3
|
||||
; CHECK-NEXT: [[CNT:%.*]] = call i32 @llvm.ctpop.i32(i32 [[AND]])
|
||||
; CHECK-NEXT: [[RES:%.*]] = icmp eq i32 [[CNT]], 3
|
||||
; CHECK-NEXT: ret i1 [[RES]]
|
||||
;
|
||||
%and = and i32 %arg, 3
|
||||
%cnt = call i32 @llvm.ctpop.i32(i32 %and)
|
||||
%res = icmp eq i32 %cnt, 3
|
||||
ret i1 %res
|
||||
}
|
||||
|
@ -305,6 +305,20 @@ define i1 @cttz_knownbits2(i32 %arg) {
|
||||
ret i1 %res
|
||||
}
|
||||
|
||||
; TODO: The icmp is unnecessary given the known bits of the input.
|
||||
define i1 @cttz_knownbits3(i32 %arg) {
|
||||
; CHECK-LABEL: @cttz_knownbits3(
|
||||
; CHECK-NEXT: [[OR:%.*]] = or i32 [[ARG:%.*]], 4
|
||||
; CHECK-NEXT: [[CNT:%.*]] = call i32 @llvm.cttz.i32(i32 [[OR]], i1 true) #2
|
||||
; CHECK-NEXT: [[RES:%.*]] = icmp eq i32 [[CNT]], 3
|
||||
; CHECK-NEXT: ret i1 [[RES]]
|
||||
;
|
||||
%or = or i32 %arg, 4
|
||||
%cnt = call i32 @llvm.cttz.i32(i32 %or, i1 true) nounwind readnone
|
||||
%res = icmp eq i32 %cnt, 3
|
||||
ret i1 %res
|
||||
}
|
||||
|
||||
define i8 @ctlz(i8 %a) {
|
||||
; CHECK-LABEL: @ctlz(
|
||||
; CHECK-NEXT: ret i8 2
|
||||
@ -338,6 +352,20 @@ define i1 @ctlz_knownbits2(i8 %arg) {
|
||||
ret i1 %res
|
||||
}
|
||||
|
||||
; TODO: The icmp is unnecessary given the known bits of the input.
|
||||
define i1 @ctlz_knownbits3(i8 %arg) {
|
||||
; CHECK-LABEL: @ctlz_knownbits3(
|
||||
; CHECK-NEXT: [[OR:%.*]] = or i8 [[ARG:%.*]], 32
|
||||
; CHECK-NEXT: [[CNT:%.*]] = call i8 @llvm.ctlz.i8(i8 [[OR]], i1 true) #2
|
||||
; CHECK-NEXT: [[RES:%.*]] = icmp eq i8 [[CNT]], 3
|
||||
; CHECK-NEXT: ret i1 [[RES]]
|
||||
;
|
||||
%or = or i8 %arg, 32
|
||||
%cnt = call i8 @llvm.ctlz.i8(i8 %or, i1 true) nounwind readnone
|
||||
%res = icmp eq i8 %cnt, 3
|
||||
ret i1 %res
|
||||
}
|
||||
|
||||
define void @cmp.simplify(i32 %a, i32 %b, i1* %c) {
|
||||
%lz = tail call i32 @llvm.ctlz.i32(i32 %a, i1 false) nounwind readnone
|
||||
%lz.cmp = icmp eq i32 %lz, 32
|
||||
|
Loading…
x
Reference in New Issue
Block a user