https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124029
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This patch fixes this but I don't have a way to fully test or benchmark it:
```
[apinski@xeond2 gcc]$ git diff
diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index 32e72128f04..91759d34356 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -4274,7 +4274,9 @@ riscv_rtx_costs (rtx x, machine_mode mode, int
outer_code, int opno ATTRIBUTE_UN
been to duplicate the operation than to CSE the constant.
3. TODO: make cost more accurate specially if riscv_const_insns
returns > 1. */
- if (outer_code == SET || GET_MODE (x) == VOIDmode)
+ if (outer_code == COMPARE)
+ *total = COSTS_N_INSNS (cost);
+ else if (outer_code == SET || GET_MODE (x) == VOIDmode)
*total = COSTS_N_INSNS (1);
}
else /* The instruction will be fetched from the constant pool. */
```
This is the code we get:
```
refine_subpel:
.LFB0:
li a5,268435456
snez a1,a1
slt a0,a0,a5
and a1,a1,a0
bne a1,zero,.L4
ret
.L4:
tail frob
```