Message ID | 20240822194705.2789364-4-patrick@rivosinc.com |
---|---|
State | New |
Headers | show |
Series | RISC-V: Improve const vector costing and expansion | expand |
> + /* Constants in range -16 ~ 15 integer or 0.0 floating-point > + can be emitted using vmv.v.i. */ > + if (satisfies_constraint_vi (x) || satisfies_constraint_Wc0 (x)) > return 1; Just a nit but while you're at it, don't you want to split this off into valid_vector_immediate or so? That would make it extensible more easily. Your call, OK either way.
On 8/22/24 13:45, Robin Dapp wrote: >> + /* Constants in range -16 ~ 15 integer or 0.0 floating-point >> + can be emitted using vmv.v.i. */ >> + if (satisfies_constraint_vi (x) || satisfies_constraint_Wc0 (x)) >> return 1; > Just a nit but while you're at it, don't you want to split this off into > valid_vector_immediate or so? That would make it extensible more easily. > > Your call, OK either way. > Makes sense - I'll update this for v2
diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index c3877008d05..dc9e9280c8c 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -2162,11 +2162,9 @@ riscv_const_insns (rtx x, bool allow_new_pseudos) if (maybe_gt (GET_MODE_SIZE (smode), UNITS_PER_WORD) && !immediate_operand (elt, Pmode)) return 0; - /* Constants from -16 to 15 can be loaded with vmv.v.i. - The Wc0, Wc1 constraints are already covered by the - vi constraint so we do not need to check them here - separately. */ - if (satisfies_constraint_vi (x)) + /* Constants in range -16 ~ 15 integer or 0.0 floating-point + can be emitted using vmv.v.i. */ + if (satisfies_constraint_vi (x) || satisfies_constraint_Wc0 (x)) return 1; /* Any int/FP constants can always be broadcast from a
The comment previously here stated that the Wc0/Wc1 cases are handled by the vi constraint but that is not true for the 0.0 Wc0 case. gcc/ChangeLog: * config/riscv/riscv.cc (riscv_const_insns): Handle 0.0 floating-point case. Signed-off-by: Patrick O'Neill <patrick@rivosinc.com> --- gcc/config/riscv/riscv.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)