public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: Jakub Jelinek <jakub@redhat.com>
Cc: gcc-patches@gcc.gnu.org, rth@gcc.gnu.org
Subject: Re: [PATCH][RFC] tree-optimization/107389 - use __builtin_assume_alignment at -O0
Date: Mon, 7 Nov 2022 10:31:21 +0000 (UTC)	[thread overview]
Message-ID: <nycvar.YFH.7.77.849.2211071027180.4294@jbgna.fhfr.qr> (raw)
In-Reply-To: <Y2jLGAFoqYy7aVTv@tucnak>

On Mon, 7 Nov 2022, Jakub Jelinek wrote:

> On Mon, Nov 07, 2022 at 10:02:11AM +0100, Richard Biener wrote:
> > The following adds a fold_builtins pass at -O0, keying off some
> > unwanted optimization and setting pointer alignment of the result
> > of __builtin_assume_alignment before removing the call.  This
> > allows libatomic calls to be elided at -O0 on s390 for
> > 
> > __uint128_t foo(__uint128_t *p)
> > {
> >   return __atomic_load_n((__uint128_t *)__builtin_assume_aligned (p, 16), 0);
> > }
> > 
> > not sure how to reliably test this though.
> > 
> > Thoughts?
> 
> Do we really need a separate pass for it?
> Can't we do it say during gimplification?

gimplification would be too early for always inline - of course since
we don't do any copy propagation the source pattern this works reliably
are limited, mostly when used directly as arguments like in the example
above.

So yes, the specific case in question would work when we elide
__builtin_assume_aligned during gimplification at -O0 (or during
the GIMPLE lower pass).

Would you prefer that?  Richard, would that work for you?

Thanks,
Richard.

> > 	PR tree-optimization/107389
> > 	* tree-pass.h (pass_fold_builtins_O0): Declare.
> > 	* passes.def (pass_fold_builtins_O0): Schedule.
> > 	* tree-ssa-ccp.cc (pass_fold_builtins_O0): Define.
> > 	(pass_fold_builtins): Template, add gate.
> > 	(pass_fold_builtins::execute): Apply alignment to the
> > 	target of __builtin_assume_aligned at -O0.  Disable most
> > 	optimizations for the -O0 pass instance.
> 
> 	Jakub
> 
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg,
Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman;
HRB 36809 (AG Nuernberg)

  reply	other threads:[~2022-11-07 10:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-07  9:02 Richard Biener
2022-11-07  9:08 ` Jakub Jelinek
2022-11-07 10:31   ` Richard Biener [this message]
2022-11-07 10:35     ` Jakub Jelinek
2022-11-07  9:48 ` Eric Botcazou

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=nycvar.YFH.7.77.849.2211071027180.4294@jbgna.fhfr.qr \
    --to=rguenther@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=rth@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).