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 tree-optimization/109667] [12/13/14 Regression] Unnecessary temporary storage used for 32-byte struct
Date: Fri, 28 Apr 2023 12:27:20 +0000	[thread overview]
Message-ID: <bug-109667-4-iAguQ502oe@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-109667-4@http.gcc.gnu.org/bugzilla/>

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.3
                 CC|                            |jamborm at gcc dot gnu.org
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2023-04-28
           Priority|P3                          |P2

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  We end up with

void assign (struct i256 * v, long int z)
{
  struct i256 r;

  <bb 2> [local count: 536870913]:
  MEM <char[24]> [(struct i256 *)&r + 8B] = {};
  r.v[0] = z_8(D);
  *v_5(D) = r;
  r ={v} {CLOBBER(eol)};
  return;
}

and I think the issue is that DSE trims the zero-initialization.  -fno-tree-dse
fixes it - not doing DSE enables SRA:

  r = {};
  r.v[0] = z_8(D);
  *v_5(D) = r;
  r ={v} {CLOBBER(eol)};

can SRA while

  MEM <char[24]> [(struct i256 *)&r + 8B] = {};
  r.v[0] = z_8(D);
  *v_5(D) = r;
  r ={v} {CLOBBER(eol)};

FAILs:

Candidate (2756): r
Created a replacement for r offset: 0, size: 64: r$v$0D.2766
...
  MEM <char[24]> [(struct i256 *)&r + 8B] = {};
  r$v$0_13 = z_8(D);
  r.v[0] = r$v$0_13;
  *v_5(D) = r;

that was pointless - compared to

Candidate (2756): r
Will attempt to totally scalarize r (UID: 2756):
Created a replacement for r offset: 0, size: 64: r$v$0D.2766
Created a replacement for r offset: 64, size: 64: r$v$1D.2767
Created a replacement for r offset: 128, size: 64: r$v$2D.2768
Created a replacement for r offset: 192, size: 64: r$v$3D.2769
...
  r$v$0_13 = 0;
  r$v$1_2 = 0;
  r$v$2_1 = 0;
  r$v$3_11 = 0;
  r$v$0_10 = z_8(D);
  v_5(D)->v[0] = r$v$0_10;
  v_5(D)->v[1] = r$v$1_2;
  v_5(D)->v[2] = r$v$2_1;
  v_5(D)->v[3] = r$v$3_11;

possibly SRA is confused by the char[24] type.  It's going to be difficult
to do better though.

  reply	other threads:[~2023-04-28 12:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-28 11:46 [Bug tree-optimization/109667] New: " chfast at gmail dot com
2023-04-28 12:27 ` rguenth at gcc dot gnu.org [this message]
2023-05-02  9:45 ` [Bug tree-optimization/109667] " jakub at gcc dot gnu.org
2023-05-02  9:56 ` jakub at gcc dot gnu.org
2023-05-08 12:27 ` 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=bug-109667-4-iAguQ502oe@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).