public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Maciej W. Rozycki" <macro@embecosm.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: Jiufu Guo <guojiufu@linux.ibm.com>,
	 YunQiang Su <yunqiang.su@cipunited.com>,
	 Rainer Orth <ro@cebitec.uni-bielefeld.de>,
	 Mike Stump <mikestump@comcast.net>,
	gcc-patches@gcc.gnu.org
Subject: Re: [PATCH 2/3] testsuite: Require 128-bit vectors for bb-slp-pr95839.c
Date: Thu, 20 Jul 2023 14:02:54 +0100 (BST)	[thread overview]
Message-ID: <alpine.DEB.2.20.2307201314580.28892@tpp.orcam.me.uk> (raw)
In-Reply-To: <CAFiYyc0RQ2H=8PYtH43DzNGp1k0tamAJAw4HvZibr+sU+aAxaA@mail.gmail.com>

On Thu, 20 Jul 2023, Richard Biener wrote:

> >  There's no such requirement in the psABI and I fail to see a plausible
> > justification.  And direct GPR<->FPR move patterns are available in the
> > backend for the V2SF mode.  Also there's no delay slot requirement even
> > for these move instructions for MIPS64r1+ ISA levels, which have this
> > paired-single FP format defined.  It seems to me a plain bug (or missed
> > optimisation if you prefer).
> 
> Definitely.  OTOH parameter/return passing for V4SFmode while
> appearantly being done in registers the backend(?) assigns BLKmode
> to the V4SFmode arguments so they get immediately spilled in the

 MIPS NewABI targets use registers to return data of small aggregate types
(effectively of up to the TImode size), so this seems reasonable to me.  
FP scalars and aggregates made of up to two fields are returned in FPRs 
and any other data is returned in GPRs:

"* Function results are returned in $2 (and $3 if needed), or $f0 (and $f2 
   if needed), as appropriate for the type.  Composite results (struct, 
   union, or array) are returned in $2/$f0 and $3/$f2 according to the 
   following rules:

"  - A struct with only one or two floating point fields is returned in 
     $f0 (and $f2 if necessary).  This is a generalization of the Fortran 
     COMPLEX case.

"  - Any other struct or union results of at most 128 bits are returned in 
     $2 (first 64 bits) and $3 (remainder, if necessary)."

Given that V4SFmode data has more than two FP fields (it's effectively an 
array of four) it is correctly returned in GPRs (even though the advantage 
of this arrangement is questionable, but the NewABI predates the invention 
of the paired-single FP format by a few years, which was only introduced 
with the MIPS V ISA, and actually implemented with the MIPS64r1 ISA even 
later).  A similar NewABI rule works here for the arguments.

 I suspect the relevant part of the backend handles it correctly for other 
modes and was missed in the update for V4SFmode, which was a change on its 
own.  The only sufficiently old version of GCC I have ready to use is 
4.1.2 and it produces the same code, so at least it does not seem to be a 
regression.

> code moving the incoming hardregisters to pseudos (or stack as in
> this case).  It comes down to the issue that Jiufu Guo is eventually
> addressing with adding SRA-style heuristics to the code chosing
> the layout of that storage.  Interestingly for the return value we get
> TImode.

 That may come from the use of the GPRs I suppose.

> Note we don't seem to be able to optimize
> 
> (insn 6 21 8 2 (set (mem/c:DI (plus:DI (reg/f:DI 78 $frame)
>                 (const_int 24 [0x18])) [1 a+8 S8 A64])
>         (reg:DI 5 $5)) "t.c":4:1 322 {*movdi_64bit}
>      (expr_list:REG_DEAD (reg:DI 5 $5)
>         (nil)))
> ...
> (insn 40 7 41 2 (set (reg:V2SF 205 [ a+8 ])
>         (mem/c:V2SF (plus:DI (reg/f:DI 78 $frame)
>                 (const_int 24 [0x18])) [1 a+8 S8 A64])) "t.c":6:23 387
> {*movv2sf}
>      (expr_list:REG_EQUIV (mem/c:V2SF (plus:DI (reg/f:DI 78 $frame)
>                 (const_int 24 [0x18])) [1 a+8 S8 A64])
>         (nil)))
> 
> for some reason.  Maybe we are afraid of the hardreg use in the store,

 I believe the reason is the relevant constraints use the `*' modifier so 
as not to spill FP values to GPRs or vice versa (ISTR a discussion as to 
why we should prevent it from happening and I don't remember the outcome, 
but overall it seems reasonable to me), so once we've spilled to memory it 
won't be undone.  That doesn't mean we should refrain from moving directly 
when data is there already in the "wrong" kind of register.

> maybe it is because the store is in the prologue (before
> NOTE_INSN_FUNCTION_BEG).  Also postreload isn't able to fix this:
> 
> (insn 6 21 8 2 (set (mem/c:DI (plus:DI (reg/f:DI 29 $sp)
>                 (const_int 24 [0x18])) [1 a+8 S8 A64])
>         (reg:DI 5 $5)) "t.c":4:1 322 {*movdi_64bit}
>      (nil))
> ...
> (insn 40 7 41 2 (set (reg:V2SF 32 $f0 [orig:205 a+8 ] [205])
>         (mem/c:V2SF (plus:DI (reg/f:DI 29 $sp)
>                 (const_int 24 [0x18])) [1 a+8 S8 A64])) "t.c":6:23 387
> {*movv2sf}
>      (expr_list:REG_EQUIV (mem/c:V2SF (plus:DI (reg/f:DI 78 $frame)
>                 (const_int 24 [0x18])) [1 a+8 S8 A64])
>         (nil)))
> 
> so something is amiss in the backend as well if you say there should be
> direct moves available.

 There are, they're alternatives #5/#6 (`mtc'/`mfc') in `*movv2sf' and 
they're handled correctly by `mips_output_move' AFAICT.  Hardware has 
always had it, so there's no ISA constraint here.

 But as I say, I'm leaving it to the backend maintainer to sort out.

  Maciej

  reply	other threads:[~2023-07-20 13:02 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-06 21:35 [PATCH 0/3] testsuite: Exclude vector tests for unsupported targets Maciej W. Rozycki
2023-07-06 21:35 ` [PATCH 1/3] testsuite: Add check for vectors of 128 bits being supported Maciej W. Rozycki
2023-07-07  6:24   ` Richard Biener
2023-07-11 15:00     ` Maciej W. Rozycki
2023-07-06 21:36 ` [PATCH 2/3] testsuite: Require 128-bit vectors for bb-slp-pr95839.c Maciej W. Rozycki
2023-07-07  6:33   ` Richard Biener
2023-07-11 15:01     ` Maciej W. Rozycki
2023-07-12  7:15       ` Richard Biener
2023-07-19 14:34         ` Maciej W. Rozycki
2023-07-20  7:15           ` Richard Biener
2023-07-20  9:16             ` Maciej W. Rozycki
2023-07-20 12:09               ` Richard Biener
2023-07-20 13:02                 ` Maciej W. Rozycki [this message]
2023-07-06 21:36 ` [PATCH 3/3] testsuite: Require vectors of doubles for pr97428.c Maciej W. Rozycki
2023-07-07  6:33   ` Richard Biener
2023-07-11 15:01     ` Maciej W. Rozycki
2023-07-12  7:15       ` Richard Biener
2023-07-19 10:29         ` Maciej W. Rozycki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.20.2307201314580.28892@tpp.orcam.me.uk \
    --to=macro@embecosm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=guojiufu@linux.ibm.com \
    --cc=mikestump@comcast.net \
    --cc=richard.guenther@gmail.com \
    --cc=ro@cebitec.uni-bielefeld.de \
    --cc=yunqiang.su@cipunited.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).