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/94600] Ignored volatile specifier on loop unrolling and bitfield misoptimization
Date: Wed, 15 Apr 2020 06:46:16 +0000	[thread overview]
Message-ID: <bug-94600-4-QVMc19HQOV@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-94600-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed on arm.  The odd thing is that the optimized GIMPLE for foo() is
much nicer:

foo ()
{
  <bb 2> [local count: 153437707]:
  MEM[(volatile struct t0 *)655404B] ={v} a0[0];
  MEM[(volatile struct t0 *)655408B] ={v} a0[1];
  MEM[(volatile struct t0 *)655412B] ={v} a0[2];
  MEM[(volatile struct t0 *)655416B] ={v} a0[3];
  MEM[(volatile struct t0 *)655420B] ={v} a0[4];
  MEM[(volatile struct t0 *)655424B] ={v} a0[5];
  return;

while for bar() we have additional stmts to construct the stack objects
though the actual stores are the same:

  <bb 2> [local count: 1073741824]:
  a01 = {};
  a02 = {};
  a03 = {};
  a04 = {};
  a05 = {};
  MEM[(struct  *)&a00] = 33556023;
  MEM[(volatile struct t0 *)655404B] ={v} a00;
  _38 = MEM[(struct  *)&a01];
  _39 = _38 & 33521664;
  _40 = _39 | 33558455;
  MEM[(struct  *)&a01] = _40;
  MEM[(volatile struct t0 *)655408B] ={v} a01;
  _41 = MEM[(struct  *)&a02];
  _42 = _41 & 33521664;
  _43 = _42 | 167774200;
  MEM[(struct  *)&a02] = _43;
  MEM[(volatile struct t0 *)655412B] ={v} a02;
  _44 = MEM[(struct  *)&a03];
  _45 = _44 & 33521664;
  _46 = _45 | 33554453;
  MEM[(struct  *)&a03] = _46;
  MEM[(volatile struct t0 *)655416B] ={v} a03;
  _47 = MEM[(struct  *)&a04];
  _48 = _47 & 33521664;
  _49 = _48 | 33554453;
  MEM[(struct  *)&a04] = _49;
  MEM[(volatile struct t0 *)655420B] ={v} a04;
  _50 = MEM[(struct  *)&a05];
  _51 = _50 & 33521664;
  _52 = _51 | 33554453;
  MEM[(struct  *)&a05] = _52;
  MEM[(volatile struct t0 *)655424B] ={v} a05;
  a00 ={v} {CLOBBER};
  a01 ={v} {CLOBBER};
  a02 ={v} {CLOBBER};
  a03 ={v} {CLOBBER};
  a04 ={v} {CLOBBER};
  a05 ={v} {CLOBBER};
  return;

I suspect that the RTL expansion for foo() applies "premature" optimization
via constant folding the aggregate initializer and thus compiling this into
partly initializing the destination which isn't valid for volatile qualified
LHSs.  For bar() there's nothing to optimize for it.

  parent reply	other threads:[~2020-04-15  6:46 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-14 23:27 [Bug middle-end/94600] New: " hp at gcc dot gnu.org
2020-04-14 23:32 ` [Bug middle-end/94600] " hp at gcc dot gnu.org
2020-04-14 23:36 ` hp at gcc dot gnu.org
2020-04-15  6:46 ` rguenth at gcc dot gnu.org [this message]
2020-04-15  7:05 ` rguenth at gcc dot gnu.org
2020-04-15  7:06 ` rguenth at gcc dot gnu.org
2020-04-15  7:07 ` rguenth at gcc dot gnu.org
2020-04-15 22:33 ` joseph at codesourcery dot com
2020-04-15 22:45 ` hp at gcc dot gnu.org
2020-07-13  6:09 ` cvs-commit at gcc dot gnu.org
2020-07-13  6:30 ` cvs-commit at gcc dot gnu.org
2020-08-13  3:13 ` cvs-commit at gcc dot gnu.org
2020-12-04 19:29 ` cvs-commit at gcc dot gnu.org
2020-12-04 19:37 ` cvs-commit at gcc dot gnu.org
2021-12-21  2:46 ` hp 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-94600-4-QVMc19HQOV@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).