public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/95669] -O3 generates more complicated code to return 8-byte struct of zeros, sometimes
Date: Mon, 15 Jun 2020 06:55:15 +0000	[thread overview]
Message-ID: <bug-95669-4-NtpW7wZHVK@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-95669-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95669

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c++                         |middle-end
             Target|                            |x86_64-*-*
   Last reconfirmed|                            |2020-06-15
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |missed-optimization

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
with 'dummy' and the implicit zero initialization of it we retain

  <bb 2> [local count: 1073741824]:
  if (a_3(D) < b_4(D)) 
    goto <bb 3>; [50.00%]
  else
    goto <bb 4>; [50.00%]

  <bb 3> [local count: 536870913]:
  D.2350 = {};
  goto <bb 5>; [100.00%]

  <bb 4> [local count: 536870913]:
  _1 = a_3(D) * b_4(D);
  D.2350.val = _1;
  MEM <unsigned int> [(void *)&D.2350 + 4B] = 1;

  <bb 5> [local count: 1073741824]:
  return D.2350;

wich generates straigt-forward code while with 'dummy' elided we manage
to completely scalarize things and do

  <bb 2> [local count: 1073741824]:
  if (a_3(D) < b_4(D)) 
    goto <bb 4>; [50.00%]
  else
    goto <bb 3>; [50.00%]

  <bb 3> [local count: 536870913]:
  _1 = a_3(D) * b_4(D);

  <bb 4> [local count: 1073741824]:
  # cstore_11 = PHI <_1(3), 0(2)>
  # cstore_10 = PHI <1(3), 0(2)>
  D.2349.ok = cstore_10;
  D.2349.val = cstore_11;
  return D.2349;

which is basically two conditional moves we expand via strange bit
shufflings because D.2349 (struct res) is assigned a register.

  reply	other threads:[~2020-06-15  6:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-14  8:52 [Bug c++/95669] New: " jzwinck at gmail dot com
2020-06-15  6:55 ` rguenth at gcc dot gnu.org [this message]
2021-05-30 22:49 ` [Bug middle-end/95669] " pinskia 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-95669-4-NtpW7wZHVK@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).