diff options
Diffstat (limited to 'llvm/test')
| -rw-r--r-- | llvm/test/Transforms/InstCombine/ctpop.ll | 16 | ||||
| -rw-r--r-- | llvm/test/Transforms/InstCombine/intrinsics.ll | 28 |
2 files changed, 44 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/ctpop.ll b/llvm/test/Transforms/InstCombine/ctpop.ll index 6bc6f973197..d49a907ffce 100644 --- a/llvm/test/Transforms/InstCombine/ctpop.ll +++ b/llvm/test/Transforms/InstCombine/ctpop.ll @@ -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 +} diff --git a/llvm/test/Transforms/InstCombine/intrinsics.ll b/llvm/test/Transforms/InstCombine/intrinsics.ll index 5654b265da5..78c98955353 100644 --- a/llvm/test/Transforms/InstCombine/intrinsics.ll +++ b/llvm/test/Transforms/InstCombine/intrinsics.ll @@ -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 |

