diff mbox series

[3/9] RISC-V: Handle 0.0 floating point pattern costing to match const_vector expander

Message ID 20240822194705.2789364-4-patrick@rivosinc.com
State New
Headers show
Series RISC-V: Improve const vector costing and expansion | expand

Commit Message

Patrick O'Neill Aug. 22, 2024, 7:46 p.m. UTC
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(-)

Comments

Robin Dapp Aug. 22, 2024, 8:45 p.m. UTC | #1
> +		/* 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.
Patrick O'Neill Aug. 23, 2024, 6:29 p.m. UTC | #2
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 mbox series

Patch

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