File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
llvm/test/Transforms/InstCombine Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -175,6 +175,7 @@ define i1 @is_pow2or0_negate_op_extra_use2(i32 %x) {
175175
176176declare i32 @llvm.ctpop.i32 (i32 )
177177declare <2 x i8 > @llvm.ctpop.v2i8 (<2 x i8 >)
178+ declare void @llvm.assume (i1 )
178179
179180; (X != 0) && (ctpop(X) u< 2) --> ctpop(X) == 1
180181
@@ -191,6 +192,22 @@ define i1 @is_pow2_ctpop(i32 %x) {
191192 ret i1 %r
192193}
193194
195+ ; tests from PR57328
196+ define i1 @is_pow2_non_zero (i32 %x ) {
197+ ; CHECK-LABEL: @is_pow2_non_zero(
198+ ; CHECK-NEXT: [[NOTZERO:%.*]] = icmp ne i32 [[X:%.*]], 0
199+ ; CHECK-NEXT: call void @llvm.assume(i1 [[NOTZERO]])
200+ ; CHECK-NEXT: [[T0:%.*]] = tail call i32 @llvm.ctpop.i32(i32 [[X]]), !range [[RNG0]]
201+ ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[T0]], 2
202+ ; CHECK-NEXT: ret i1 [[CMP]]
203+ ;
204+ %notzero = icmp ne i32 %x , 0
205+ call void @llvm.assume (i1 %notzero )
206+ %t0 = tail call i32 @llvm.ctpop.i32 (i32 %x )
207+ %cmp = icmp ult i32 %t0 , 2
208+ ret i1 %cmp
209+ }
210+
194211define i1 @is_pow2_ctpop_logical (i32 %x ) {
195212; CHECK-LABEL: @is_pow2_ctpop_logical(
196213; CHECK-NEXT: [[T0:%.*]] = tail call i32 @llvm.ctpop.i32(i32 [[X:%.*]]), !range [[RNG0]]
You can’t perform that action at this time.
0 commit comments