diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp --- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp @@ -10911,6 +10911,18 @@ SDValue Neg = DAG.getNegative(C, DL, VT); return DAG.getNode(ISD::AND, DL, VT, Neg, TrueV); } + // (riscvisd::select_cc x, 0, ne, x, 1) -> (add x, (setcc x, 0, eq)) + // (riscvisd::select_cc x, 0, eq, 1, x) -> (add x, (setcc x, 0, eq)) + if (((isOneConstant(FalseV) && LHS == TrueV && + CCVal == ISD::CondCode::SETNE) || + (isOneConstant(TrueV) && LHS == FalseV && + CCVal == ISD::CondCode::SETEQ)) && + isNullConstant(RHS)) { + // freeze it to be safe. + LHS = DAG.getFreeze(LHS); + SDValue C = DAG.getSetCC(DL, VT, LHS, RHS, ISD::CondCode::SETEQ); + return DAG.getNode(ISD::ADD, DL, VT, LHS, C); + } } return SDValue(); diff --git a/llvm/test/CodeGen/RISCV/double-convert-strict.ll b/llvm/test/CodeGen/RISCV/double-convert-strict.ll --- a/llvm/test/CodeGen/RISCV/double-convert-strict.ll +++ b/llvm/test/CodeGen/RISCV/double-convert-strict.ll @@ -134,10 +134,8 @@ ; CHECKIFD-LABEL: fcvt_wu_d_multiple_use: ; CHECKIFD: # %bb.0: ; CHECKIFD-NEXT: fcvt.wu.d a0, fa0, rtz -; CHECKIFD-NEXT: bnez a0, .LBB4_2 -; CHECKIFD-NEXT: # %bb.1: -; CHECKIFD-NEXT: li a0, 1 -; CHECKIFD-NEXT: .LBB4_2: +; CHECKIFD-NEXT: seqz a1, a0 +; CHECKIFD-NEXT: add a0, a0, a1 ; CHECKIFD-NEXT: ret ; ; RV32I-LABEL: fcvt_wu_d_multiple_use: @@ -145,10 +143,8 @@ ; RV32I-NEXT: addi sp, sp, -16 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill ; RV32I-NEXT: call __fixunsdfsi@plt -; RV32I-NEXT: bnez a0, .LBB4_2 -; RV32I-NEXT: # %bb.1: -; RV32I-NEXT: li a0, 1 -; RV32I-NEXT: .LBB4_2: +; RV32I-NEXT: seqz a1, a0 +; RV32I-NEXT: add a0, a0, a1 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload ; RV32I-NEXT: addi sp, sp, 16 ; RV32I-NEXT: ret @@ -158,10 +154,8 @@ ; RV64I-NEXT: addi sp, sp, -16 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill ; RV64I-NEXT: call __fixunsdfsi@plt -; RV64I-NEXT: bnez a0, .LBB4_2 -; RV64I-NEXT: # %bb.1: -; RV64I-NEXT: li a0, 1 -; RV64I-NEXT: .LBB4_2: +; RV64I-NEXT: seqz a1, a0 +; RV64I-NEXT: add a0, a0, a1 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload ; RV64I-NEXT: addi sp, sp, 16 ; RV64I-NEXT: ret diff --git a/llvm/test/CodeGen/RISCV/double-convert.ll b/llvm/test/CodeGen/RISCV/double-convert.ll --- a/llvm/test/CodeGen/RISCV/double-convert.ll +++ b/llvm/test/CodeGen/RISCV/double-convert.ll @@ -236,10 +236,8 @@ ; CHECKIFD-LABEL: fcvt_wu_d_multiple_use: ; CHECKIFD: # %bb.0: ; CHECKIFD-NEXT: fcvt.wu.d a0, fa0, rtz -; CHECKIFD-NEXT: bnez a0, .LBB5_2 -; CHECKIFD-NEXT: # %bb.1: -; CHECKIFD-NEXT: li a0, 1 -; CHECKIFD-NEXT: .LBB5_2: +; CHECKIFD-NEXT: seqz a1, a0 +; CHECKIFD-NEXT: add a0, a0, a1 ; CHECKIFD-NEXT: ret ; ; RV32I-LABEL: fcvt_wu_d_multiple_use: @@ -247,10 +245,8 @@ ; RV32I-NEXT: addi sp, sp, -16 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill ; RV32I-NEXT: call __fixunsdfsi@plt -; RV32I-NEXT: bnez a0, .LBB5_2 -; RV32I-NEXT: # %bb.1: -; RV32I-NEXT: li a0, 1 -; RV32I-NEXT: .LBB5_2: +; RV32I-NEXT: seqz a1, a0 +; RV32I-NEXT: add a0, a0, a1 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload ; RV32I-NEXT: addi sp, sp, 16 ; RV32I-NEXT: ret @@ -260,10 +256,8 @@ ; RV64I-NEXT: addi sp, sp, -16 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill ; RV64I-NEXT: call __fixunsdfsi@plt -; RV64I-NEXT: bnez a0, .LBB5_2 -; RV64I-NEXT: # %bb.1: -; RV64I-NEXT: li a0, 1 -; RV64I-NEXT: .LBB5_2: +; RV64I-NEXT: seqz a1, a0 +; RV64I-NEXT: add a0, a0, a1 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload ; RV64I-NEXT: addi sp, sp, 16 ; RV64I-NEXT: ret diff --git a/llvm/test/CodeGen/RISCV/float-convert-strict.ll b/llvm/test/CodeGen/RISCV/float-convert-strict.ll --- a/llvm/test/CodeGen/RISCV/float-convert-strict.ll +++ b/llvm/test/CodeGen/RISCV/float-convert-strict.ll @@ -76,10 +76,8 @@ ; CHECKIF-LABEL: fcvt_wu_s_multiple_use: ; CHECKIF: # %bb.0: ; CHECKIF-NEXT: fcvt.wu.s a0, fa0, rtz -; CHECKIF-NEXT: bnez a0, .LBB2_2 -; CHECKIF-NEXT: # %bb.1: -; CHECKIF-NEXT: li a0, 1 -; CHECKIF-NEXT: .LBB2_2: +; CHECKIF-NEXT: seqz a1, a0 +; CHECKIF-NEXT: add a0, a0, a1 ; CHECKIF-NEXT: ret ; ; RV32I-LABEL: fcvt_wu_s_multiple_use: @@ -87,10 +85,8 @@ ; RV32I-NEXT: addi sp, sp, -16 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill ; RV32I-NEXT: call __fixunssfsi@plt -; RV32I-NEXT: bnez a0, .LBB2_2 -; RV32I-NEXT: # %bb.1: -; RV32I-NEXT: li a0, 1 -; RV32I-NEXT: .LBB2_2: +; RV32I-NEXT: seqz a1, a0 +; RV32I-NEXT: add a0, a0, a1 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload ; RV32I-NEXT: addi sp, sp, 16 ; RV32I-NEXT: ret @@ -100,10 +96,8 @@ ; RV64I-NEXT: addi sp, sp, -16 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill ; RV64I-NEXT: call __fixunssfsi@plt -; RV64I-NEXT: bnez a0, .LBB2_2 -; RV64I-NEXT: # %bb.1: -; RV64I-NEXT: li a0, 1 -; RV64I-NEXT: .LBB2_2: +; RV64I-NEXT: seqz a1, a0 +; RV64I-NEXT: add a0, a0, a1 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload ; RV64I-NEXT: addi sp, sp, 16 ; RV64I-NEXT: ret diff --git a/llvm/test/CodeGen/RISCV/float-convert.ll b/llvm/test/CodeGen/RISCV/float-convert.ll --- a/llvm/test/CodeGen/RISCV/float-convert.ll +++ b/llvm/test/CodeGen/RISCV/float-convert.ll @@ -167,10 +167,8 @@ ; CHECKIF-LABEL: fcvt_wu_s_multiple_use: ; CHECKIF: # %bb.0: ; CHECKIF-NEXT: fcvt.wu.s a0, fa0, rtz -; CHECKIF-NEXT: bnez a0, .LBB3_2 -; CHECKIF-NEXT: # %bb.1: -; CHECKIF-NEXT: li a0, 1 -; CHECKIF-NEXT: .LBB3_2: +; CHECKIF-NEXT: seqz a1, a0 +; CHECKIF-NEXT: add a0, a0, a1 ; CHECKIF-NEXT: ret ; ; RV32I-LABEL: fcvt_wu_s_multiple_use: @@ -178,10 +176,8 @@ ; RV32I-NEXT: addi sp, sp, -16 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill ; RV32I-NEXT: call __fixunssfsi@plt -; RV32I-NEXT: bnez a0, .LBB3_2 -; RV32I-NEXT: # %bb.1: -; RV32I-NEXT: li a0, 1 -; RV32I-NEXT: .LBB3_2: +; RV32I-NEXT: seqz a1, a0 +; RV32I-NEXT: add a0, a0, a1 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload ; RV32I-NEXT: addi sp, sp, 16 ; RV32I-NEXT: ret @@ -191,10 +187,8 @@ ; RV64I-NEXT: addi sp, sp, -16 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill ; RV64I-NEXT: call __fixunssfsi@plt -; RV64I-NEXT: bnez a0, .LBB3_2 -; RV64I-NEXT: # %bb.1: -; RV64I-NEXT: li a0, 1 -; RV64I-NEXT: .LBB3_2: +; RV64I-NEXT: seqz a1, a0 +; RV64I-NEXT: add a0, a0, a1 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload ; RV64I-NEXT: addi sp, sp, 16 ; RV64I-NEXT: ret diff --git a/llvm/test/CodeGen/RISCV/forced-atomics.ll b/llvm/test/CodeGen/RISCV/forced-atomics.ll --- a/llvm/test/CodeGen/RISCV/forced-atomics.ll +++ b/llvm/test/CodeGen/RISCV/forced-atomics.ll @@ -1169,9 +1169,10 @@ ; RV32-NO-ATOMIC-NEXT: sw s0, 8(sp) # 4-byte Folded Spill ; RV32-NO-ATOMIC-NEXT: mv s0, a0 ; RV32-NO-ATOMIC-NEXT: lw a1, 0(a0) -; RV32-NO-ATOMIC-NEXT: j .LBB25_2 ; RV32-NO-ATOMIC-NEXT: .LBB25_1: # %atomicrmw.start -; RV32-NO-ATOMIC-NEXT: # in Loop: Header=BB25_2 Depth=1 +; RV32-NO-ATOMIC-NEXT: # =>This Inner Loop Header: Depth=1 +; RV32-NO-ATOMIC-NEXT: seqz a2, a1 +; RV32-NO-ATOMIC-NEXT: add a2, a1, a2 ; RV32-NO-ATOMIC-NEXT: sw a1, 4(sp) ; RV32-NO-ATOMIC-NEXT: addi a1, sp, 4 ; RV32-NO-ATOMIC-NEXT: li a3, 5 @@ -1179,16 +1180,8 @@ ; RV32-NO-ATOMIC-NEXT: mv a0, s0 ; RV32-NO-ATOMIC-NEXT: call __atomic_compare_exchange_4@plt ; RV32-NO-ATOMIC-NEXT: lw a1, 4(sp) -; RV32-NO-ATOMIC-NEXT: bnez a0, .LBB25_4 -; RV32-NO-ATOMIC-NEXT: .LBB25_2: # %atomicrmw.start -; RV32-NO-ATOMIC-NEXT: # =>This Inner Loop Header: Depth=1 -; RV32-NO-ATOMIC-NEXT: mv a2, a1 -; RV32-NO-ATOMIC-NEXT: bnez a1, .LBB25_1 -; RV32-NO-ATOMIC-NEXT: # %bb.3: # %atomicrmw.start -; RV32-NO-ATOMIC-NEXT: # in Loop: Header=BB25_2 Depth=1 -; RV32-NO-ATOMIC-NEXT: li a2, 1 -; RV32-NO-ATOMIC-NEXT: j .LBB25_1 -; RV32-NO-ATOMIC-NEXT: .LBB25_4: # %atomicrmw.end +; RV32-NO-ATOMIC-NEXT: beqz a0, .LBB25_1 +; RV32-NO-ATOMIC-NEXT: # %bb.2: # %atomicrmw.end ; RV32-NO-ATOMIC-NEXT: mv a0, a1 ; RV32-NO-ATOMIC-NEXT: lw ra, 12(sp) # 4-byte Folded Reload ; RV32-NO-ATOMIC-NEXT: lw s0, 8(sp) # 4-byte Folded Reload @@ -2740,9 +2733,10 @@ ; RV64-NO-ATOMIC-NEXT: sd s0, 16(sp) # 8-byte Folded Spill ; RV64-NO-ATOMIC-NEXT: mv s0, a0 ; RV64-NO-ATOMIC-NEXT: ld a1, 0(a0) -; RV64-NO-ATOMIC-NEXT: j .LBB51_2 ; RV64-NO-ATOMIC-NEXT: .LBB51_1: # %atomicrmw.start -; RV64-NO-ATOMIC-NEXT: # in Loop: Header=BB51_2 Depth=1 +; RV64-NO-ATOMIC-NEXT: # =>This Inner Loop Header: Depth=1 +; RV64-NO-ATOMIC-NEXT: seqz a2, a1 +; RV64-NO-ATOMIC-NEXT: add a2, a1, a2 ; RV64-NO-ATOMIC-NEXT: sd a1, 8(sp) ; RV64-NO-ATOMIC-NEXT: addi a1, sp, 8 ; RV64-NO-ATOMIC-NEXT: li a3, 5 @@ -2750,16 +2744,8 @@ ; RV64-NO-ATOMIC-NEXT: mv a0, s0 ; RV64-NO-ATOMIC-NEXT: call __atomic_compare_exchange_8@plt ; RV64-NO-ATOMIC-NEXT: ld a1, 8(sp) -; RV64-NO-ATOMIC-NEXT: bnez a0, .LBB51_4 -; RV64-NO-ATOMIC-NEXT: .LBB51_2: # %atomicrmw.start -; RV64-NO-ATOMIC-NEXT: # =>This Inner Loop Header: Depth=1 -; RV64-NO-ATOMIC-NEXT: mv a2, a1 -; RV64-NO-ATOMIC-NEXT: bnez a1, .LBB51_1 -; RV64-NO-ATOMIC-NEXT: # %bb.3: # %atomicrmw.start -; RV64-NO-ATOMIC-NEXT: # in Loop: Header=BB51_2 Depth=1 -; RV64-NO-ATOMIC-NEXT: li a2, 1 -; RV64-NO-ATOMIC-NEXT: j .LBB51_1 -; RV64-NO-ATOMIC-NEXT: .LBB51_4: # %atomicrmw.end +; RV64-NO-ATOMIC-NEXT: beqz a0, .LBB51_1 +; RV64-NO-ATOMIC-NEXT: # %bb.2: # %atomicrmw.end ; RV64-NO-ATOMIC-NEXT: mv a0, a1 ; RV64-NO-ATOMIC-NEXT: ld ra, 24(sp) # 8-byte Folded Reload ; RV64-NO-ATOMIC-NEXT: ld s0, 16(sp) # 8-byte Folded Reload diff --git a/llvm/test/CodeGen/RISCV/half-convert-strict.ll b/llvm/test/CodeGen/RISCV/half-convert-strict.ll --- a/llvm/test/CodeGen/RISCV/half-convert-strict.ll +++ b/llvm/test/CodeGen/RISCV/half-convert-strict.ll @@ -173,48 +173,38 @@ ; CHECKIZFH-LABEL: fcvt_wu_h_multiple_use: ; CHECKIZFH: # %bb.0: ; CHECKIZFH-NEXT: fcvt.wu.h a0, fa0, rtz -; CHECKIZFH-NEXT: bnez a0, .LBB4_2 -; CHECKIZFH-NEXT: # %bb.1: -; CHECKIZFH-NEXT: li a0, 1 -; CHECKIZFH-NEXT: .LBB4_2: +; CHECKIZFH-NEXT: seqz a1, a0 +; CHECKIZFH-NEXT: add a0, a0, a1 ; CHECKIZFH-NEXT: ret ; ; RV32IDZFH-LABEL: fcvt_wu_h_multiple_use: ; RV32IDZFH: # %bb.0: ; RV32IDZFH-NEXT: fcvt.wu.h a0, fa0, rtz -; RV32IDZFH-NEXT: bnez a0, .LBB4_2 -; RV32IDZFH-NEXT: # %bb.1: -; RV32IDZFH-NEXT: li a0, 1 -; RV32IDZFH-NEXT: .LBB4_2: +; RV32IDZFH-NEXT: seqz a1, a0 +; RV32IDZFH-NEXT: add a0, a0, a1 ; RV32IDZFH-NEXT: ret ; ; RV64IDZFH-LABEL: fcvt_wu_h_multiple_use: ; RV64IDZFH: # %bb.0: ; RV64IDZFH-NEXT: fcvt.wu.h a0, fa0, rtz -; RV64IDZFH-NEXT: bnez a0, .LBB4_2 -; RV64IDZFH-NEXT: # %bb.1: -; RV64IDZFH-NEXT: li a0, 1 -; RV64IDZFH-NEXT: .LBB4_2: +; RV64IDZFH-NEXT: seqz a1, a0 +; RV64IDZFH-NEXT: add a0, a0, a1 ; RV64IDZFH-NEXT: ret ; ; CHECK32-IZFHMIN-LABEL: fcvt_wu_h_multiple_use: ; CHECK32-IZFHMIN: # %bb.0: ; CHECK32-IZFHMIN-NEXT: fcvt.s.h ft0, fa0 ; CHECK32-IZFHMIN-NEXT: fcvt.wu.s a0, ft0, rtz -; CHECK32-IZFHMIN-NEXT: bnez a0, .LBB4_2 -; CHECK32-IZFHMIN-NEXT: # %bb.1: -; CHECK32-IZFHMIN-NEXT: li a0, 1 -; CHECK32-IZFHMIN-NEXT: .LBB4_2: +; CHECK32-IZFHMIN-NEXT: seqz a1, a0 +; CHECK32-IZFHMIN-NEXT: add a0, a0, a1 ; CHECK32-IZFHMIN-NEXT: ret ; ; CHECK64-IZFHMIN-LABEL: fcvt_wu_h_multiple_use: ; CHECK64-IZFHMIN: # %bb.0: ; CHECK64-IZFHMIN-NEXT: fcvt.s.h ft0, fa0 ; CHECK64-IZFHMIN-NEXT: fcvt.wu.s a0, ft0, rtz -; CHECK64-IZFHMIN-NEXT: bnez a0, .LBB4_2 -; CHECK64-IZFHMIN-NEXT: # %bb.1: -; CHECK64-IZFHMIN-NEXT: li a0, 1 -; CHECK64-IZFHMIN-NEXT: .LBB4_2: +; CHECK64-IZFHMIN-NEXT: seqz a1, a0 +; CHECK64-IZFHMIN-NEXT: add a0, a0, a1 ; CHECK64-IZFHMIN-NEXT: ret %a = call i32 @llvm.experimental.constrained.fptoui.i32.f16(half %x, metadata !"fpexcept.strict") strictfp %b = icmp eq i32 %a, 0 diff --git a/llvm/test/CodeGen/RISCV/half-convert.ll b/llvm/test/CodeGen/RISCV/half-convert.ll --- a/llvm/test/CodeGen/RISCV/half-convert.ll +++ b/llvm/test/CodeGen/RISCV/half-convert.ll @@ -735,28 +735,22 @@ ; CHECKIZFH-LABEL: fcvt_wu_h_multiple_use: ; CHECKIZFH: # %bb.0: ; CHECKIZFH-NEXT: fcvt.wu.h a0, fa0, rtz -; CHECKIZFH-NEXT: bnez a0, .LBB7_2 -; CHECKIZFH-NEXT: # %bb.1: -; CHECKIZFH-NEXT: li a0, 1 -; CHECKIZFH-NEXT: .LBB7_2: +; CHECKIZFH-NEXT: seqz a1, a0 +; CHECKIZFH-NEXT: add a0, a0, a1 ; CHECKIZFH-NEXT: ret ; ; RV32IDZFH-LABEL: fcvt_wu_h_multiple_use: ; RV32IDZFH: # %bb.0: ; RV32IDZFH-NEXT: fcvt.wu.h a0, fa0, rtz -; RV32IDZFH-NEXT: bnez a0, .LBB7_2 -; RV32IDZFH-NEXT: # %bb.1: -; RV32IDZFH-NEXT: li a0, 1 -; RV32IDZFH-NEXT: .LBB7_2: +; RV32IDZFH-NEXT: seqz a1, a0 +; RV32IDZFH-NEXT: add a0, a0, a1 ; RV32IDZFH-NEXT: ret ; ; RV64IDZFH-LABEL: fcvt_wu_h_multiple_use: ; RV64IDZFH: # %bb.0: ; RV64IDZFH-NEXT: fcvt.wu.h a0, fa0, rtz -; RV64IDZFH-NEXT: bnez a0, .LBB7_2 -; RV64IDZFH-NEXT: # %bb.1: -; RV64IDZFH-NEXT: li a0, 1 -; RV64IDZFH-NEXT: .LBB7_2: +; RV64IDZFH-NEXT: seqz a1, a0 +; RV64IDZFH-NEXT: add a0, a0, a1 ; RV64IDZFH-NEXT: ret ; ; RV32I-LABEL: fcvt_wu_h_multiple_use: @@ -767,10 +761,8 @@ ; RV32I-NEXT: srli a0, a0, 16 ; RV32I-NEXT: call __extendhfsf2@plt ; RV32I-NEXT: call __fixunssfsi@plt -; RV32I-NEXT: bnez a0, .LBB7_2 -; RV32I-NEXT: # %bb.1: -; RV32I-NEXT: li a0, 1 -; RV32I-NEXT: .LBB7_2: +; RV32I-NEXT: seqz a1, a0 +; RV32I-NEXT: add a0, a0, a1 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload ; RV32I-NEXT: addi sp, sp, 16 ; RV32I-NEXT: ret @@ -783,10 +775,8 @@ ; RV64I-NEXT: srli a0, a0, 48 ; RV64I-NEXT: call __extendhfsf2@plt ; RV64I-NEXT: call __fixunssfdi@plt -; RV64I-NEXT: bnez a0, .LBB7_2 -; RV64I-NEXT: # %bb.1: -; RV64I-NEXT: li a0, 1 -; RV64I-NEXT: .LBB7_2: +; RV64I-NEXT: seqz a1, a0 +; RV64I-NEXT: add a0, a0, a1 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload ; RV64I-NEXT: addi sp, sp, 16 ; RV64I-NEXT: ret @@ -795,20 +785,16 @@ ; CHECK32-IZFHMIN: # %bb.0: ; CHECK32-IZFHMIN-NEXT: fcvt.s.h ft0, fa0 ; CHECK32-IZFHMIN-NEXT: fcvt.wu.s a0, ft0, rtz -; CHECK32-IZFHMIN-NEXT: bnez a0, .LBB7_2 -; CHECK32-IZFHMIN-NEXT: # %bb.1: -; CHECK32-IZFHMIN-NEXT: li a0, 1 -; CHECK32-IZFHMIN-NEXT: .LBB7_2: +; CHECK32-IZFHMIN-NEXT: seqz a1, a0 +; CHECK32-IZFHMIN-NEXT: add a0, a0, a1 ; CHECK32-IZFHMIN-NEXT: ret ; ; CHECK64-IZFHMIN-LABEL: fcvt_wu_h_multiple_use: ; CHECK64-IZFHMIN: # %bb.0: ; CHECK64-IZFHMIN-NEXT: fcvt.s.h ft0, fa0 ; CHECK64-IZFHMIN-NEXT: fcvt.wu.s a0, ft0, rtz -; CHECK64-IZFHMIN-NEXT: bnez a0, .LBB7_2 -; CHECK64-IZFHMIN-NEXT: # %bb.1: -; CHECK64-IZFHMIN-NEXT: li a0, 1 -; CHECK64-IZFHMIN-NEXT: .LBB7_2: +; CHECK64-IZFHMIN-NEXT: seqz a1, a0 +; CHECK64-IZFHMIN-NEXT: add a0, a0, a1 ; CHECK64-IZFHMIN-NEXT: ret %a = fptoui half %x to i32 %b = icmp eq i32 %a, 0 diff --git a/llvm/test/CodeGen/RISCV/min-max.ll b/llvm/test/CodeGen/RISCV/min-max.ll --- a/llvm/test/CodeGen/RISCV/min-max.ll +++ b/llvm/test/CodeGen/RISCV/min-max.ll @@ -719,3 +719,51 @@ %c = call i64 @llvm.smin.i64(i64 %a, i64 -1) ret i64 %c } + +define i64 @umax_i64_one(i64 %a, i64 %b) { +; RV32I-LABEL: umax_i64_one: +; RV32I: # %bb.0: +; RV32I-NEXT: mv a2, a0 +; RV32I-NEXT: beqz a1, .LBB28_3 +; RV32I-NEXT: # %bb.1: +; RV32I-NEXT: beqz a1, .LBB28_4 +; RV32I-NEXT: .LBB28_2: +; RV32I-NEXT: ret +; RV32I-NEXT: .LBB28_3: +; RV32I-NEXT: li a0, 1 +; RV32I-NEXT: bnez a1, .LBB28_2 +; RV32I-NEXT: .LBB28_4: +; RV32I-NEXT: seqz a0, a2 +; RV32I-NEXT: add a0, a2, a0 +; RV32I-NEXT: ret +; +; RV64I-LABEL: umax_i64_one: +; RV64I: # %bb.0: +; RV64I-NEXT: seqz a1, a0 +; RV64I-NEXT: add a0, a0, a1 +; RV64I-NEXT: ret +; +; RV32ZBB-LABEL: umax_i64_one: +; RV32ZBB: # %bb.0: +; RV32ZBB-NEXT: mv a2, a0 +; RV32ZBB-NEXT: li a3, 1 +; RV32ZBB-NEXT: beqz a1, .LBB28_3 +; RV32ZBB-NEXT: # %bb.1: +; RV32ZBB-NEXT: beqz a1, .LBB28_4 +; RV32ZBB-NEXT: .LBB28_2: +; RV32ZBB-NEXT: ret +; RV32ZBB-NEXT: .LBB28_3: +; RV32ZBB-NEXT: li a0, 1 +; RV32ZBB-NEXT: bnez a1, .LBB28_2 +; RV32ZBB-NEXT: .LBB28_4: +; RV32ZBB-NEXT: maxu a0, a2, a3 +; RV32ZBB-NEXT: ret +; +; RV64ZBB-LABEL: umax_i64_one: +; RV64ZBB: # %bb.0: +; RV64ZBB-NEXT: li a1, 1 +; RV64ZBB-NEXT: maxu a0, a0, a1 +; RV64ZBB-NEXT: ret + %c = call i64 @llvm.umax.i64(i64 %a, i64 1) + ret i64 %c +}