public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/47477] [4.7/4.8/4.9 regression] Sub-optimal mov at end of method
Date: Tue, 22 Oct 2013 14:56:00 -0000	[thread overview]
Message-ID: <bug-47477-4-cIGD3klrYd@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-47477-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #18 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Kai Tietz from comment #17)
> What optimization you expect here?  I see by the new type-demotion pass some
> changes in optimized tree-output:

This one is for vectorization, try it with -O3 -mavx2 and look what vectorized
loop we get.  With type demotion and promotion for the vectorized loops
(perhaps only for that and not for the scalar loops), you could get similar
vectorization to say:
short a[1024], b[1024];

void
foo (void)
{
  int i;
  for (i = 0; i < 1024; i++)
    {
      unsigned short c = ((short)(a[i] << 8) >> 8) + 5U;
      unsigned short d = b[i] + 12U;
      a[i] = c + d;
    }
}
though even in this case I still couldn't achieve the sign extension to be
actually performed as 16-bit left + right (signed) shift, while I guess that
would lead to even better code.
Or look at how we vectorize:
short a[1024], b[1024];

void
foo (void)
{
  int i;
  for (i = 0; i < 1024; i++)
    {
      unsigned char e = a[i];
      short c = e + 5;
      long long d = (long long) b[i] + 12;
      a[i] = c + d;
    }
}
(note, here forwprop pass already performs type promotion, instead of
converting a[i] to unsigned char and back to short, it computes a[i] & 255 in
short mode) and how we could instead with type demotions:
short a[1024], b[1024];

void
foo (void)
{
  int i;
  for (i = 0; i < 1024; i++)
    {
      unsigned short c = (a[i] & 0xff) + 5U;
      unsigned short d = b[i] + 12U;
      a[i] = c + d;
    }
}

These are all admittedly artificial testcases, but I've seen tons of loops
where multiple types were vectorized and I think in some portion of those loops
we could either use just a single type size, or at least decrease the number of
conversions and different type sizes in the vectorized loops.


  parent reply	other threads:[~2013-10-22 14:56 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-26 16:54 [Bug rtl-optimization/47477] New: [4.6 " tony.poppleton at gmail dot com
2011-01-27  7:08 ` [Bug rtl-optimization/47477] " hjl.tools at gmail dot com
2011-01-27 11:51 ` rguenth at gcc dot gnu.org
2011-01-27 17:34 ` jakub at gcc dot gnu.org
2011-01-27 17:58 ` jakub at gcc dot gnu.org
2011-01-27 19:43 ` tony.poppleton at gmail dot com
2011-01-28 11:31 ` rguenth at gcc dot gnu.org
2011-01-29 20:37 ` jakub at gcc dot gnu.org
2011-02-08 14:40 ` rguenth at gcc dot gnu.org
2011-02-08 14:41 ` rguenth at gcc dot gnu.org
2011-02-21 16:19 ` jakub at gcc dot gnu.org
2012-01-02 11:36 ` [Bug rtl-optimization/47477] [4.6/4.7/4.8 " jakub at gcc dot gnu.org
2012-03-06 12:48 ` jakub at gcc dot gnu.org
2012-11-30 16:27 ` jakub at gcc dot gnu.org
2013-03-22 14:46 ` [Bug rtl-optimization/47477] [4.6/4.7/4.8/4.9 " jakub at gcc dot gnu.org
2013-04-10  1:44 ` tony.poppleton at gmail dot com
2013-05-31 11:03 ` [Bug rtl-optimization/47477] [4.7/4.8/4.9 " jakub at gcc dot gnu.org
2013-10-16  9:49 ` jakub at gcc dot gnu.org
2013-10-22 13:40 ` jakub at gcc dot gnu.org
2013-10-22 14:18 ` ktietz at gcc dot gnu.org
2013-10-22 14:56 ` jakub at gcc dot gnu.org [this message]
2014-05-22  9:07 ` [Bug rtl-optimization/47477] [4.7/4.8/4.9/4.10 " rguenth at gcc dot gnu.org
2014-12-19 13:40 ` [Bug rtl-optimization/47477] [4.8/4.9/5 " jakub at gcc dot gnu.org
2015-02-13 20:18 ` law at gcc dot gnu.org
2015-02-13 20:20 ` [Bug rtl-optimization/47477] [4.8/4.9 " law at redhat dot com
2015-02-17  5:22 ` law at redhat dot com
2015-06-23  8:20 ` rguenth at gcc dot gnu.org
2015-06-26 20:13 ` [Bug rtl-optimization/47477] [4.9 " jakub at gcc dot gnu.org
2015-06-26 20:35 ` jakub 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=bug-47477-4-cIGD3klrYd@http.gcc.gnu.org/bugzilla/ \
    --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).