On Tue, Aug 10, 2021 at 10:33 AM Jojo R via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > Some target like RISC-V allow to group vector register as a whole, > and only operate part of it in fact, but the 'init-regs' pass will add > initialization > for uninitialized registers. Add this hook to reject this action for reducing > instruction.
Are these groups "visible"? That is, are the pseudos multi-reg pseudos? I wonder if there's a more generic way to tame down initregs w/o introducing a new target hook. Btw, initregs is a red herring - it ideally should go away. See PR61810. So instead of adding to it can you see whether disabling the pass for RISC-V works w/o fallout (and add a comment to the PR)? Maybe some more RTL literate (in particular DF literate) can look at the remaining issue. Richard, did you ever have a look into the "issue" that initregs covers up (whatever that exactly is)? Thanks, Richard. > gcc/ > * init-regs.c (initialize_uninitialized_regs): Call > register_reject_init_p. > * target.def (register_reject_init_p): New hook. > * doc/tm.texi.in: Add TARGET_REGISTER_REJECT_INIT_P. > * doc/tm.texi: Regenerated. > --- > gcc/doc/tm.texi | 6 ++++++ > gcc/doc/tm.texi.in | 2 ++ > gcc/init-regs.c | 5 +++++ > gcc/target.def | 8 ++++++++ > 4 files changed, 21 insertions(+) > > diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi > index a30fdcbbf3d6..83fd5496ca3f 100644 > --- a/gcc/doc/tm.texi > +++ b/gcc/doc/tm.texi > @@ -12588,3 +12588,9 @@ Return an RTX representing @var{tagged_pointer} with > its tag set to zero. > Store the result in @var{target} if convenient. > The default clears the top byte of the original pointer. > @end deftypefn > + > +@deftypefn {Target Hook} bool TARGET_REGISTER_REJECT_INIT_P (rtx @var{reg}) > +This target hook should return @code{true} if reject initialization for a > uninitialized @var{reg}. > + > +The default value of this hook is @code{NULL}. > +@end deftypefn > diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in > index 611fc500ac86..13174ce66d59 100644 > --- a/gcc/doc/tm.texi.in > +++ b/gcc/doc/tm.texi.in > @@ -8180,3 +8180,5 @@ maintainer is familiar with. > @hook TARGET_MEMTAG_EXTRACT_TAG > > @hook TARGET_MEMTAG_UNTAGGED_POINTER > + > +@hook TARGET_REGISTER_REJECT_INIT_P > diff --git a/gcc/init-regs.c b/gcc/init-regs.c > index 72e898f3e334..51c0d669d30b 100644 > --- a/gcc/init-regs.c > +++ b/gcc/init-regs.c > @@ -21,6 +21,7 @@ along with GCC; see the file COPYING3. If not see > #include "system.h" > #include "coretypes.h" > #include "backend.h" > +#include "target.h" > #include "rtl.h" > #include "tree.h" > #include "df.h" > @@ -101,6 +102,10 @@ initialize_uninitialized_regs (void) > rtx_insn *move_insn; > rtx reg = DF_REF_REAL_REG (use); > > + if (targetm.register_reject_init_p > + && targetm.register_reject_init_p (reg)) > + continue; > + > bitmap_set_bit (already_genned, regno); > > start_sequence (); > diff --git a/gcc/target.def b/gcc/target.def > index 7676d5e626e3..c2b54421618d 100644 > --- a/gcc/target.def > +++ b/gcc/target.def > @@ -4545,6 +4545,14 @@ by a subtarget.", > unsigned HOST_WIDE_INT, (void), > NULL) > > +/* Return true if reject initialization for a uninitialized register. */ > +DEFHOOK > +(register_reject_init_p, > + "This target hook should return @code{true} if reject initialization for a > uninitialized @var{reg}.\n\ > +\n\ > +The default value of this hook is @code{NULL}.", > + bool, (rtx reg), NULL) > + > /* Functions relating to calls - argument passing, returns, etc. */ > /* Members of struct call have no special macro prefix. */ > HOOK_VECTOR (TARGET_CALLS, calls) > -- > 2.24.3 (Apple Git-128) >