@@ -187,14 +187,14 @@ define i64 @bittest_31_i64(i64 %a) nounwind {
187187;
188188; RV64ZBS-LABEL: bittest_31_i64:
189189; RV64ZBS: # %bb.0:
190- ; RV64ZBS-NEXT: not a0, a0
191- ; RV64ZBS-NEXT: bexti a0, a0, 31
190+ ; RV64ZBS-NEXT: srliw a0, a0, 31
191+ ; RV64ZBS-NEXT: xori a0, a0, 1
192192; RV64ZBS-NEXT: ret
193193;
194194; RV64XTHEADBS-LABEL: bittest_31_i64:
195195; RV64XTHEADBS: # %bb.0:
196- ; RV64XTHEADBS-NEXT: not a0, a0
197- ; RV64XTHEADBS-NEXT: th.tst a0, a0, 31
196+ ; RV64XTHEADBS-NEXT: srliw a0, a0, 31
197+ ; RV64XTHEADBS-NEXT: xori a0, a0, 1
198198; RV64XTHEADBS-NEXT: ret
199199 %shr = lshr i64 %a , 31
200200 %not = xor i64 %shr , -1
@@ -3509,75 +3509,35 @@ define void @bit_64_1_nz_branch_i64(i64 %0) {
35093509}
35103510
35113511define i32 @bittest_31_andeq0_i64 (i64 %x ) {
3512- ; RV32I-LABEL: bittest_31_andeq0_i64:
3513- ; RV32I: # %bb.0:
3514- ; RV32I-NEXT: lui a1, 524288
3515- ; RV32I-NEXT: and a0, a0, a1
3516- ; RV32I-NEXT: seqz a0, a0
3517- ; RV32I-NEXT: ret
3518- ;
3519- ; RV64I-LABEL: bittest_31_andeq0_i64:
3520- ; RV64I: # %bb.0:
3521- ; RV64I-NEXT: srliw a0, a0, 31
3522- ; RV64I-NEXT: slli a0, a0, 31
3523- ; RV64I-NEXT: seqz a0, a0
3524- ; RV64I-NEXT: ret
3525- ;
3526- ; ZBS-LABEL: bittest_31_andeq0_i64:
3527- ; ZBS: # %bb.0:
3528- ; ZBS-NEXT: not a0, a0
3529- ; ZBS-NEXT: bexti a0, a0, 31
3530- ; ZBS-NEXT: ret
3512+ ; RV32-LABEL: bittest_31_andeq0_i64:
3513+ ; RV32: # %bb.0:
3514+ ; RV32-NEXT: srli a0, a0, 31
3515+ ; RV32-NEXT: xori a0, a0, 1
3516+ ; RV32-NEXT: ret
35313517;
3532- ; XTHEADBS -LABEL: bittest_31_andeq0_i64:
3533- ; XTHEADBS : # %bb.0:
3534- ; XTHEADBS -NEXT: not a0, a0
3535- ; XTHEADBS -NEXT: th.tst a0, a0, 31
3536- ; XTHEADBS -NEXT: ret
3518+ ; RV64 -LABEL: bittest_31_andeq0_i64:
3519+ ; RV64 : # %bb.0:
3520+ ; RV64 -NEXT: srliw a0, a0, 31
3521+ ; RV64 -NEXT: xori a0, a0, 1
3522+ ; RV64 -NEXT: ret
35373523 %and = and i64 %x , 2147483648
35383524 %cmp = icmp eq i64 %and , 0
35393525 %conv = zext i1 %cmp to i32
35403526 ret i32 %conv
35413527}
35423528
35433529define i32 @bittest_63_andeq0_i64 (i64 %x ) {
3544- ; RV32I-LABEL: bittest_63_andeq0_i64:
3545- ; RV32I: # %bb.0:
3546- ; RV32I-NEXT: lui a0, 524288
3547- ; RV32I-NEXT: and a0, a1, a0
3548- ; RV32I-NEXT: seqz a0, a0
3549- ; RV32I-NEXT: ret
3550- ;
3551- ; RV64I-LABEL: bittest_63_andeq0_i64:
3552- ; RV64I: # %bb.0:
3553- ; RV64I-NEXT: srli a0, a0, 63
3554- ; RV64I-NEXT: slli a0, a0, 63
3555- ; RV64I-NEXT: seqz a0, a0
3556- ; RV64I-NEXT: ret
3557- ;
3558- ; RV32ZBS-LABEL: bittest_63_andeq0_i64:
3559- ; RV32ZBS: # %bb.0:
3560- ; RV32ZBS-NEXT: not a0, a1
3561- ; RV32ZBS-NEXT: bexti a0, a0, 31
3562- ; RV32ZBS-NEXT: ret
3563- ;
3564- ; RV64ZBS-LABEL: bittest_63_andeq0_i64:
3565- ; RV64ZBS: # %bb.0:
3566- ; RV64ZBS-NEXT: not a0, a0
3567- ; RV64ZBS-NEXT: bexti a0, a0, 63
3568- ; RV64ZBS-NEXT: ret
3569- ;
3570- ; RV32XTHEADBS-LABEL: bittest_63_andeq0_i64:
3571- ; RV32XTHEADBS: # %bb.0:
3572- ; RV32XTHEADBS-NEXT: not a0, a1
3573- ; RV32XTHEADBS-NEXT: th.tst a0, a0, 31
3574- ; RV32XTHEADBS-NEXT: ret
3530+ ; RV32-LABEL: bittest_63_andeq0_i64:
3531+ ; RV32: # %bb.0:
3532+ ; RV32-NEXT: srli a1, a1, 31
3533+ ; RV32-NEXT: xori a0, a1, 1
3534+ ; RV32-NEXT: ret
35753535;
3576- ; RV64XTHEADBS -LABEL: bittest_63_andeq0_i64:
3577- ; RV64XTHEADBS : # %bb.0:
3578- ; RV64XTHEADBS -NEXT: not a0, a0
3579- ; RV64XTHEADBS -NEXT: th.tst a0, a0, 63
3580- ; RV64XTHEADBS -NEXT: ret
3536+ ; RV64 -LABEL: bittest_63_andeq0_i64:
3537+ ; RV64 : # %bb.0:
3538+ ; RV64 -NEXT: srli a0, a0, 63
3539+ ; RV64 -NEXT: xori a0, a0, 1
3540+ ; RV64 -NEXT: ret
35813541 %and = and i64 %x , 9223372036854775808
35823542 %cmp = icmp eq i64 %and , 0
35833543 %conv = zext i1 %cmp to i32
@@ -3587,14 +3547,13 @@ define i32 @bittest_63_andeq0_i64(i64 %x) {
35873547define i32 @bittest_31_slt0_i32 (i32 %x , i1 %y ) {
35883548; RV32-LABEL: bittest_31_slt0_i32:
35893549; RV32: # %bb.0:
3590- ; RV32-NEXT: slti a0, a0, 0
3550+ ; RV32-NEXT: srli a0, a0, 31
35913551; RV32-NEXT: and a0, a0, a1
35923552; RV32-NEXT: ret
35933553;
35943554; RV64-LABEL: bittest_31_slt0_i32:
35953555; RV64: # %bb.0:
3596- ; RV64-NEXT: sext.w a0, a0
3597- ; RV64-NEXT: slti a0, a0, 0
3556+ ; RV64-NEXT: srliw a0, a0, 31
35983557; RV64-NEXT: and a0, a0, a1
35993558; RV64-NEXT: ret
36003559 %cmp = icmp slt i32 %x , 0
@@ -3607,14 +3566,13 @@ define i32 @bittest_63_slt0_i64(i32 %x, i1 %y) {
36073566; RV32-LABEL: bittest_63_slt0_i64:
36083567; RV32: # %bb.0:
36093568; RV32-NEXT: srai a0, a0, 31
3610- ; RV32-NEXT: slti a0, a0, 0
3569+ ; RV32-NEXT: srli a0, a0, 31
36113570; RV32-NEXT: and a0, a0, a1
36123571; RV32-NEXT: ret
36133572;
36143573; RV64-LABEL: bittest_63_slt0_i64:
36153574; RV64: # %bb.0:
3616- ; RV64-NEXT: sext.w a0, a0
3617- ; RV64-NEXT: slti a0, a0, 0
3575+ ; RV64-NEXT: srliw a0, a0, 31
36183576; RV64-NEXT: and a0, a0, a1
36193577; RV64-NEXT: ret
36203578 %ext = sext i32 %x to i64
0 commit comments