https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110748
--- Comment #8 from Vineet Gupta <vineetg at gcc dot gnu.org> --- (In reply to Jeffrey A. Law from comment #5) > I'd bet it's const_0_operand not allowing CONST_DOUBLE. Correct. > The question is what unintended side effects we'd have if we allowed > CONST_DOUBLE 0.0 in const_0_operand. Exactly. I had the same concern. I do have a hack which creates a new predicate and that seems to do the trick. +(define_predicate "const_0hf_operand" + (and (match_code "const_double") + (match_test "op == CONST0_RTX (GET_MODE (op))"))) + +(define_predicate "reg_or_0_operand_inc_hf" + (ior (match_operand 0 "reg_or_0_operand") + (match_operand 0 "const_0hf_operand"))) diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc - if (!register_operand (dest, mode) && !reg_or_0_operand (src, mode)) + if (!register_operand (dest, mode) && !reg_or_0_operand_inc_hf (src, mode)) { And it seems to be generating the desired int 0 for double 0.0. However to Kito's point, this indeed works in gcc 12 so I first need to bisect what regressed it in 13.