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
Subject: Re: [PATCH][v2] tree-optimization/107389 - honor __builtin_assume_alignment at -O0
Date: Tue, 8 Nov 2022 13:38:27 +0000 (UTC)	[thread overview]
Message-ID: <nycvar.YFH.7.77.849.2211081334490.4294@jbgna.fhfr.qr> (raw)
In-Reply-To: <Y2pUHswt4peOqElT@tucnak>

On Tue, 8 Nov 2022, Jakub Jelinek wrote:

> On Tue, Nov 08, 2022 at 01:53:48PM +0100, Richard Biener wrote:
> > The following makes sure to set alignment information on the LHS
> > of __builtin_assume_alignment calls even when not optimizing so
> > uses as arguments to builtin functions like memcpy or __atomic_load_n
> > can be reflected at RTL expansion time.
> > 
> > Bootstrap and regtest running on x86_64-unknown-linux-gnu, OK?
> > 
> > Thanks,
> > Richard.
> > 
> > 	PR tree-optimization/107389
> > 	* gimple-low.cc (lower_builtin_assume_aligned): New.
> > 	(lower_stmt): Call it.
> > 
> > 	* gcc.dg/pr107389.c: New testcase.
> > ---
> >  gcc/gimple-low.cc               | 41 +++++++++++++++++++++++++++++++++
> >  gcc/testsuite/gcc.dg/pr107389.c | 13 +++++++++++
> >  2 files changed, 54 insertions(+)
> >  create mode 100644 gcc/testsuite/gcc.dg/pr107389.c
> > 
> > diff --git a/gcc/gimple-low.cc b/gcc/gimple-low.cc
> > index 512aa9feada..f9bcb772163 100644
> > --- a/gcc/gimple-low.cc
> > +++ b/gcc/gimple-low.cc
> > @@ -84,6 +84,7 @@ static void lower_try_catch (gimple_stmt_iterator *, struct lower_data *);
> >  static void lower_gimple_return (gimple_stmt_iterator *, struct lower_data *);
> >  static void lower_builtin_setjmp (gimple_stmt_iterator *);
> >  static void lower_builtin_posix_memalign (gimple_stmt_iterator *);
> > +static void lower_builtin_assume_aligned (gimple_stmt_iterator *);
> >  
> >  
> >  /* Lower the body of current_function_decl from High GIMPLE into Low
> > @@ -768,6 +769,13 @@ lower_stmt (gimple_stmt_iterator *gsi, struct lower_data *data)
> >  		lower_builtin_posix_memalign (gsi);
> >  		return;
> >  	      }
> > +	    else if (DECL_FUNCTION_CODE (decl) == BUILT_IN_ASSUME_ALIGNED
> > +		     && !optimize)
> > +	      {
> > +		lower_builtin_assume_aligned (gsi);
> > +		data->cannot_fallthru = false;
> > +		return;
> > +	      }
> >  	  }
> >  
> >  	if (decl && (flags_from_decl_or_type (decl) & ECF_NORETURN))
> > @@ -1310,6 +1318,39 @@ lower_builtin_posix_memalign (gimple_stmt_iterator *gsi)
> >    gsi_insert_after (gsi, stmt, GSI_NEW_STMT);
> >    gsi_insert_after (gsi, gimple_build_label (noalign_label), GSI_NEW_STMT);
> >  }
> > +
> > +/* Lower calls to __builtin_assume_aligned when not optimizing.  */
> > +
> > +static void
> > +lower_builtin_assume_aligned (gimple_stmt_iterator *gsi)
> > +{
> > +  gcall *call = as_a <gcall *> (gsi_stmt (*gsi));
> > +
> > +  tree lhs = gimple_call_lhs (call);
> > +  if (!lhs || !POINTER_TYPE_P (TREE_TYPE (lhs)))
> > +    return;
> 
> I think nothing checks that TREE_CODE (lhs) == SSA_NAME,
> that isn't guaranteed before ssa pass.

Yep, noticed in the testsuite and fixed.

Richard.

      reply	other threads:[~2022-11-08 13:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-08 12:53 Richard Biener
2022-11-08 13:05 ` Jakub Jelinek
2022-11-08 13:38   ` Richard Biener [this message]

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