Robin Dapp b2fc711494 lra: Perform cycle detection for moves with clobber. [PR123381]
In the PR code we have the somewhat rare case that we need to reload
a vector subreg of a scalar register, (subreg:V2HI (reg:DI)).
What complicates things is that the test is compiled with
-mrvv-vector-bits=zvl, so VLS-only mode.
Unfortunately, we can still get VLA-named modes that are actually VLS
modes (i.e. that have a constant number of units).

For moving real VLS modes we simply use

 (define_insn_and_split "*mov<mode>"
   [(set (match_operand:VLS_AVL_IMM 0 "reg_or_mem_operand" "=vr, m, vr")
 	(match_operand:VLS_AVL_IMM 1 "reg_or_mem_operand" "  m,vr, vr"))]

Here, lra recognizes cycle danger, quickly switches to the memory
alternative and the resulting code is as expected - we perform a vector
load from that memory the DImode reg was spilled to.

For VLA (named) modes the mov insn is

(define_insn_and_split "*mov<V_FRACT:mode><P:mode>_lra"
  [(set (match_operand:V_FRACT 0 "reg_or_mem_operand" "=vr, m,vr")
	(match_operand:V_FRACT 1 "reg_or_mem_operand" "  m,vr,vr"))
   (clobber (match_scratch:P 2 "=&r,&r,X"))]

The extra clobber here is an optimization:  For modes smaller than a full
register we want to store the actual size, rather than always the full
vector size.  If that mode size happens to exceed 32, instead of using an
immediate we need to move it to a register so vsetvl can consume it.

As the second mov insn above has three operands lra never checks for cycle
danger and promptly creates a cycle :)  This patch loosens the conditions on
the cycle check by allowing a third operand that is a clobber.

	PR rtl-optimization/123381

gcc/ChangeLog:

	* lra-constraints.cc (process_alt_operands): Detect cycles in
	three-operand moves with clobber.
	(curr_insn_transform): Don't write back a scratch operand.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/pr123381.c: New test.
2026-02-24 21:48:47 +01:00
2026-01-02 09:56:11 +01:00
2026-02-05 00:16:28 +00:00
2026-02-16 00:16:25 +00:00
2026-01-10 00:16:49 +00:00
2026-02-06 00:16:39 +00:00
2026-01-02 09:56:11 +01:00
2026-02-22 00:16:27 +00:00
2026-01-02 10:47:06 +01:00
2026-01-16 00:16:30 +00:00
2026-02-23 00:16:26 +00:00
2026-01-10 00:16:49 +00:00
2026-01-30 00:16:31 +00:00
2026-02-24 00:16:30 +00:00
2026-02-24 00:16:30 +00:00
2026-01-14 00:16:30 +00:00
2026-02-24 00:16:30 +00:00
2026-01-02 09:56:11 +01:00
2026-02-13 00:16:32 +00:00
2026-02-13 00:16:32 +00:00
2026-01-02 09:56:11 +01:00
2026-02-06 00:16:39 +00:00
2026-01-02 00:16:23 +00:00
2026-01-02 09:56:11 +01:00
2026-01-02 09:56:11 +01:00
2026-01-02 09:56:11 +01:00
2026-01-27 00:16:29 +00:00
2026-02-20 00:16:32 +00:00

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.
Description
No description provided
Readme 4.2 GiB
Languages
C++ 30.7%
C 30.2%
Ada 14.4%
D 6.1%
Go 5.7%
Other 12.4%