Skip to content

Commit 24b9a24

Browse files
committed
[InstCombine] Add pre-commit tests. NFC.
1 parent ed77df5 commit 24b9a24

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

llvm/test/Transforms/InstCombine/ispow2.ll

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,3 +1554,29 @@ entry:
15541554
%sel = select i1 %cmp1, i1 true, i1 %cmp2
15551555
ret i1 %sel
15561556
}
1557+
1558+
define i1 @is_power2_or_zero_with_range(i32 %x) {
1559+
; CHECK-LABEL: @is_power2_or_zero_with_range(
1560+
; CHECK-NEXT: [[CTPOP:%.*]] = call range(i32 1, 33) i32 @llvm.ctpop.i32(i32 [[X:%.*]])
1561+
; CHECK-NEXT: [[RES:%.*]] = icmp ult i32 [[CTPOP]], 2
1562+
; CHECK-NEXT: ret i1 [[RES]]
1563+
;
1564+
%ctpop = call range(i32 1, 33) i32 @llvm.ctpop.i32(i32 %x)
1565+
%cmp = icmp eq i32 %ctpop, 1
1566+
%notzero = icmp eq i32 %x, 0
1567+
%res = select i1 %notzero, i1 true, i1 %cmp
1568+
ret i1 %res
1569+
}
1570+
1571+
define i1 @is_power2_or_zero_inv_with_range(i32 %x) {
1572+
; CHECK-LABEL: @is_power2_or_zero_inv_with_range(
1573+
; CHECK-NEXT: [[CTPOP:%.*]] = call range(i32 1, 33) i32 @llvm.ctpop.i32(i32 [[X:%.*]])
1574+
; CHECK-NEXT: [[RES:%.*]] = icmp ugt i32 [[CTPOP]], 1
1575+
; CHECK-NEXT: ret i1 [[RES]]
1576+
;
1577+
%ctpop = call range(i32 1, 33) i32 @llvm.ctpop.i32(i32 %x)
1578+
%cmp = icmp ne i32 %ctpop, 1
1579+
%notzero = icmp ne i32 %x, 0
1580+
%res = select i1 %notzero, i1 %cmp, i1 false
1581+
ret i1 %res
1582+
}

0 commit comments

Comments
 (0)