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.
---
 gcc/config/riscv/riscv.cc |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

gcc-riscv-expand-conditional-move-thead-op.diff
Index: gcc/gcc/config/riscv/riscv.cc
===================================================================
--- gcc.orig/gcc/config/riscv/riscv.cc
+++ gcc/gcc/config/riscv/riscv.cc
@@ -4097,8 +4097,8 @@ riscv_expand_conditional_move (rtx dest,
       && 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;
 

Reply via email to