From: Maciej W. Rozycki Date: Wed, 22 Nov 2023 01:18:27 +0000 (+0000) Subject: RISC-V: Also accept constants for T-Head cond-move comparison operands X-Git-Tag: basepoints/gcc-15~4420 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eeb112542f9a93974ee17d582ba649c50af95c86;p=thirdparty%2Fgcc.git RISC-V: Also accept constants for T-Head cond-move comparison operands There is no need for the requirement for conditional-move comparison operands to be stricter for T-Head targets than for other targets and limit them to registers only. Constants will be reloaded if required just as with branches or other-target conditional-move operations and there is no extra overhead specific to the T-Head case. This enables more opportunities for a branchless sequence to be produced. gcc/ * config/riscv/riscv.cc (riscv_expand_conditional_move): Also accept constants for T-Head comparison operands. --- diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index e418ccc90613..ac2e76f4bedf 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -4126,8 +4126,8 @@ riscv_expand_conditional_move (rtx dest, rtx op, rtx cons, rtx alt) && reg_or_0_operand (cons, mode) && reg_or_0_operand (alt, mode) && (GET_MODE (op) == mode || GET_MODE (op) == E_VOIDmode) - && GET_MODE (op0) == mode - && GET_MODE (op1) == mode + && (GET_MODE (op0) == mode || CONST_INT_P (op0)) + && (GET_MODE (op1) == mode || CONST_INT_P (op1)) && (code == EQ || code == NE)) need_eq_ne_p = true;