public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "wilson at specifixinc dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/21111] IA-64 NaT consumption faults due to uninitialized register reads
Date: Tue, 19 Apr 2005 23:05:00 -0000	[thread overview]
Message-ID: <20050419230522.25697.qmail@sourceware.org> (raw)
In-Reply-To: <20050419203158.21111.wilson@gcc.gnu.org>


------- Additional Comments From wilson at specifixinc dot com  2005-04-19 23:05 -------
Subject: Re:  IA-64 NaT consumption faults due to uninitialized
 register reads

pinskia at gcc dot gnu dot org wrote:
> ------- Additional Comments From pinskia at gcc dot gnu dot org  2005-04-19 20:47 -------
> To me, the target specific code should be the one to fix this problem up and not the middle-end or at 
> least have a hook for it so you don't mess around with other targets getting the speed up.  Anyways 
> seems like someone thought it would be cool if they did this, oh well.

The change I am suggesting should not hurt performance, and I expect 
that it would actually help performance in many cases.

Currently, the first assignment to a structure is a bitfield insert.

If we zero the structure before the first assignment, then combine will 
give us a simple assignment instead, which will be faster than a 
bitfield insert for most targets.  This may also allow other assignments 
to be combined in, giving further benefits.  (There can be multiple 
first assignments if there are multiple blocks where the structure 
becomes live.)

I agree that the optimizations being performed by tree-ssa are useful 
here, but one must not be confused by the big picture issues here into 
ignoring the details.  Emitting a bit-field insert when only a simple 
assignment is needed is wrong.  It may cause performance loss on many 
targets, and it causes core dumps on IA-64.

Take a look at this example.
struct s { unsigned long i : 32; unsigned long j : 32;};
int i;
struct s
sub (void)
{
   struct s foo;
   foo.i = i;
   return foo;
}
Compiling this for x86-64 on mainline, I get 10 instructions, which 
perform two bit-field insertions.  Compiling this with gcc-3.3, I get 7 
instructions which perform one bit-field insertion.

I think the optimal code is two instructions, one to load i into the low 
part of the return register, and one to return.  The upper bits of the 
structure are don't care bits, so we can set them to anything we want. 
There is no need for any bitfield insertion here at all.

Mainline does even worse than gcc-3 here because in order to decompose 
the structure it creates a fake j assignment, and then we end up 
emitting bitfield insertion code for the fake j assignment, even though 
this code is completely useless.  Furthermore, the RTL optimizer is not 
able to delete this fake j assignment, because it is a bitfield insert.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21111


  parent reply	other threads:[~2005-04-19 23:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-19 20:32 [Bug middle-end/21111] New: " wilson at gcc dot gnu dot org
2005-04-19 20:41 ` [Bug middle-end/21111] " wilson at gcc dot gnu dot org
2005-04-19 20:47 ` pinskia at gcc dot gnu dot org
2005-04-19 23:05 ` wilson at specifixinc dot com [this message]
2005-07-19  6:26 ` pinskia at gcc dot gnu dot org
     [not found] <bug-21111-4@http.gcc.gnu.org/bugzilla/>
2012-01-11 13:05 ` rguenth at gcc dot gnu.org
2021-10-11  7:53 ` rguenth at gcc dot gnu.org
2021-10-11  8:48 ` amonakov at gcc dot gnu.org
2021-10-11  9:18 ` rguenth at gcc dot gnu.org

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=20050419230522.25697.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).