public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <jeffreyalaw@gmail.com>
To: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH]middle-end Use subregs to expand COMPLEX_EXPR to set the lowpart.
Date: Sun, 12 Jun 2022 11:27:13 -0600	[thread overview]
Message-ID: <c296bc75-c730-f2bb-45d0-8ccfd0b2cfc0@gmail.com> (raw)
In-Reply-To: <patch-15778-tamar@arm.com>



On 6/9/2022 1:52 AM, Tamar Christina via Gcc-patches wrote:
> Hi All,
>
> When lowering COMPLEX_EXPR we currently emit two VEC_EXTRACTs.  One for the
> lowpart and one for the highpart.
>
> The problem with this is that in RTL the lvalue of the RTX is the only thing
> tying the two instructions together.
>
> This means that e.g. combine is unable to try to combine the two instructions
> for setting the lowpart and highpart.
>
> For ISAs that have bit extract instructions we can eliminate one of the extracts
> if, and only if we're setting the entire complex number.
>
> This change changes the expand code when we're setting the entire complex number
> to generate a subreg for the lowpart instead of a vec_extract.
>
> This allows us to optimize sequences such as:
Just a note.  I regularly see subregs significantly interfere with 
optimization, particularly register allocation.  So be aware that 
subregs can often get in the way of generating good code.  When changing 
something to use subregs I like to run real benchmarks rather than 
working with code snippets.


>
> _Complex int f(int a, int b) {
>      _Complex int t = a + b * 1i;
>      return t;
> }
>
> from:
>
> f:
> 	bfi     x2, x0, 0, 32
> 	bfi     x2, x1, 32, 32
> 	mov     x0, x2
> 	ret
>
> into:
>
> f:
> 	bfi	x0, x1, 32, 32
> 	ret
>
> I have also confirmed the codegen for x86_64 did not change.
>
> Bootstrapped Regtested on aarch64-none-linux-gnu, x86_64-pc-linux-gnu
> and no issues.
>
> Ok for master?
>
> Thanks,
> Tamar
>
> gcc/ChangeLog:
>
> 	* emit-rtl.cc (validate_subreg): Accept subregs of complex modes.
> 	* expr.cc (emit_move_complex_parts): Emit subreg of lowpart if possible.
>
> gcc/testsuite/ChangeLog:
>
> 	* g++.target/aarch64/complex-init.C: New test.
OK.

On a related topic, any thoughts on keeping complex objects as complex 
types/modes through gimple and into at least parts of the RTL pipeline?

The way complex arithmetic instructions work on our chip is going to be 
extremely tough to utilize in GCC -- we really need to the complex 
types/arithmetic up through RTL generation at the least. Ideally we'd 
even expose complex modes all the way to final.    Is that something 
y'all could benefit from as well?  Have y'all poked at this problem at all?

jeff


  reply	other threads:[~2022-06-12 17:27 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-09  7:52 Tamar Christina
2022-06-12 17:27 ` Jeff Law [this message]
2022-06-13 10:19   ` Tamar Christina
2022-06-13 17:42     ` Jeff Law
2022-06-13 11:54   ` Richard Biener
2022-06-13 17:34     ` Jeff Law
2022-06-15 11:36       ` Richard Sandiford
2022-06-16 11:22         ` Tamar Christina
2022-06-24 21:54         ` Jeff Law
2022-06-13  8:40 ` Richard Sandiford
2022-06-16 11:28   ` Tamar Christina
2022-06-17 17:13     ` Richard Sandiford
2022-06-20  8:00       ` Richard Sandiford
2022-07-05 15:05         ` Tamar Christina
2022-07-05 16:11           ` Richard Sandiford
2022-08-29 10:52             ` Richard Biener

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=c296bc75-c730-f2bb-45d0-8ccfd0b2cfc0@gmail.com \
    --to=jeffreyalaw@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    /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).