[Bug target/121073] [16 Regression] RISC-V: ICE during RTL pass: avlprop insn does not satisfy its constraints

2025-07-23 Thread rdapp at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121073

Robin Dapp  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|ASSIGNED|RESOLVED

--- Comment #4 from Robin Dapp  ---
Should be fixed on trunk.

[Bug target/121073] [16 Regression] RISC-V: ICE during RTL pass: avlprop insn does not satisfy its constraints

2025-07-23 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121073

--- Comment #3 from GCC Commits  ---
The master branch has been updated by Robin Dapp :

https://gcc.gnu.org/g:f796f819c35cc08e0a6e7242aee92eb96f62a3b5

commit r16-2452-gf796f819c35cc08e0a6e7242aee92eb96f62a3b5
Author: Robin Dapp 
Date:   Thu Jul 17 11:09:43 2025 +0200

RISC-V: Rework broadcast handling [PR121073].

During the last weeks it became clear that our current broadcast
handling needs an overhaul in order to improve maintainability.
PR121073 showed that my intermediate fix wasn't enough and caused
regressions.

This patch now goes a first step towards untangling broadcast
(vmv.v.x), "set first" (vmv.s.x), and zero-strided load (vlse).
Also can_be_broadcast_p is rewritten and strided_broadcast_p is
introduced to make the distinction clear directly in the predicates.

Due to the pervasiveness of the patterns I needed to touch a lot
of places and tried to clear up some things while at it.  The patch
therefore also introduces new helpers expand_broadcast for vmv.v.x
that dispatches to regular as well as strided broadcast and
expand_set_first that does the same thing for vmv.s.x.

The non-strided fallbacks are now implemented as splitters of the
strided variants.  This makes it easier to see where and when things
happen.

The test cases I touched appeared wrong to me so this patch sets a new
baseline for some of the scalar_move tests.

There is still work to be done but IMHO that can be deferred: It would
be clearer if the three broadcast-like variants differed not just in
name but also in RTL pattern so matching is not as confusing.  Right now
vmv.v.x and vmv.s.x only differ in the mask and are interchangeable by
just changing it from "all ones" to a "single one".

As last time, I regtested on rv64 and rv32 with strided_broadcast turned
on and off.  Note there are regressions cond_fma_fnma-[78].c.  Those are
due to the patch exposing more fwprop/late-combine opportunities.  For
fma/fnma we don't yet have proper costing for vv/vx in place but I'll
expect that to be addressed soon and figured we can live with those for
the time being.

PR target/121073

gcc/ChangeLog:

* config/riscv/autovec-opt.md: Use new helpers.
* config/riscv/autovec.md: Ditto.
* config/riscv/predicates.md (strided_broadcast_mask_operand):
New predicate.
(strided_broadcast_operand): Ditto.
(any_broadcast_operand): Ditto.
* config/riscv/riscv-protos.h (expand_broadcast): Declare.
(expand_set_first): Ditto.
(expand_set_first_tu): Ditto.
(strided_broadcast_p): Ditto.
* config/riscv/riscv-string.cc (expand_vec_setmem): Use new
helpers.
* config/riscv/riscv-v.cc (expand_broadcast): New functionk.
(expand_set_first): Ditto.
(expand_set_first_tu): Ditto.
(expand_const_vec_duplicate): Use new helpers.
(expand_const_vector_duplicate_repeating): Ditto.
(expand_const_vector_duplicate_default): Ditto.
(sew64_scalar_helper): Ditto.
(expand_vector_init_merge_repeating_sequence): Ditto.
(expand_reduction): Ditto.
(strided_broadcast_p): New function.
(whole_reg_to_reg_move_p): Use new helpers.
* config/riscv/riscv-vector-builtins-bases.cc: Use either
broadcast or strided broadcast.
* config/riscv/riscv-vector-builtins.cc
(function_expander::use_ternop_insn):
Ditto.
(function_expander::use_widen_ternop_insn): Ditto.
(function_expander::use_scalar_broadcast_insn): Ditto.
* config/riscv/riscv-vector-builtins.h: Declare scalar
broadcast.
* config/riscv/vector.md (*pred_broadcast): Split into
regular and strided broadcast.
(*pred_broadcast_zvfh): Split.
(pred_broadcast_zvfh): Ditto.
(*pred_broadcast_zvfhmin): Ditto.
(@pred_strided_broadcast): Ditto.
(*pred_strided_broadcast): Ditto.
(*pred_strided_broadcast_zvfhmin): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vls-vlmax/repeat-6.c: Adjust test
expectation.
* gcc.target/riscv/rvv/base/scalar_move-5.c: Ditto.
* gcc.target/riscv/rvv/base/scalar_move-6.c: Ditto.
* gcc.target/riscv/rvv/base/scalar_move-7.c: Ditto.
* gcc.target/riscv/rvv/base/scalar_move-8.c: Ditto.
* gcc.target/riscv/rvv/base/scalar_move-9.c: Ditto.
* gcc.target/riscv/rvv/pr121073.c: New test.

[Bug target/121073] [16 Regression] RISC-V: ICE during RTL pass: avlprop insn does not satisfy its constraints

2025-07-15 Thread law at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121073

Jeffrey A. Law  changed:

   What|Removed |Added

   Last reconfirmed||2025-07-15
 Ever confirmed|0   |1
 Status|UNCONFIRMED |ASSIGNED

[Bug target/121073] [16 Regression] RISC-V: ICE during RTL pass: avlprop insn does not satisfy its constraints

2025-07-15 Thread rdapp at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121073

--- Comment #2 from Robin Dapp  ---
Yes, the issue is that Wdm was a memory constraint before, giving reload more
freedom.  In the case here we have a real mask operand that only the strided
alternatives support.  Need to think of another solution.

[Bug target/121073] [16 Regression] RISC-V: ICE during RTL pass: avlprop insn does not satisfy its constraints

2025-07-15 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121073

Richard Biener  changed:

   What|Removed |Added

   Target Milestone|--- |16.0
 Target||riscv
   Keywords||ice-on-valid-code

[Bug target/121073] [16 Regression] RISC-V: ICE during RTL pass: avlprop insn does not satisfy its constraints

2025-07-15 Thread rdapp at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121073

--- Comment #1 from Robin Dapp  ---
That's very likely due to my recent broadcast changes.  Will have a look.