public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenther at suse dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/109791] -Wstringop-overflow warning with -O3 and _GLIBCXX_USE_CXX11_ABI=0
Date: Thu, 11 May 2023 11:36:12 +0000	[thread overview]
Message-ID: <bug-109791-4-5lTC0C97WO@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-109791-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #7 from rguenther at suse dot de <rguenther at suse dot de> ---
On Thu, 11 May 2023, aldyh at gcc dot gnu.org wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109791
> 
> --- Comment #6 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
> 
> > but the issue with the PHI node remains unless we sink the &str part
> > (but there's many uses of __i_14).  I guess it's still the "easiest"
> > way to get rangers help.  Aka make
> > 
> >  # __i_14' = PHI <1(10), 2(9)>
> >  __i_14 = &str + __i_14'; // would be a POINTER_PLUS_EXPR
> > 
> > it's probably still not a complete fix but maybe a good start.  Of course
> > it increases the number of stmts - &MEM[&str + 1B] was an 'invariant'
> > (of course the PHI result isn't).  There's not a good place for this
> > transform - we never "fold" PHIs (and this would be an un-folding).
> 
> Ughh, that sucks.  Let's see if Andrew has any ideas, but on my end I won't be
> able to work on prange until much later this cycle-- assuming I finish what I
> have on my plate.

So the idea with the above is of course that via regular folding
and value-numbering we can simplify the compare to a compare of
just the offsets and for those ranger already works.  The expression
is quite obfuscated of course and as said the strlen pass placement
doesn't help (it's before forwprop and VRP).

That said, the place to transform the PHI node is probably the same
where degenerate PHIs are removed.

For the testcase the PHI is created quite early by cunrolli.

I have a patch splitting the PHI.  We then still have

  # _69 = PHI <1(9), 2(8)>
  __i_44 = &str + _69;
...
  <bb 14> [local count: 402445658]:
  _51 = (unsigned long) &MEM <char[3]> [(void *)&str + 2B];
  _4 = (unsigned long) __i_44;
  _12 = -_4;
  _119 = _51 + 18446744073709551615;
  _48 = _119 - _4;
  _46 = _48 > 13;
  if (_46 != 0)
    goto <bb 15>; [64.00%]

and also

  _31 = &MEM <char[3]> [(void *)&str + 3B] <= __i_44;

so at least for the latter we are missing a simplification
pattern - it should simplify the compare to

  _31 = 3 <= _69

possibly (unsigned)(p p+ offset) should be changed to
(unsigned)p + offset and thus likewise (unsigned) &MEM[&str + 4B] into
(unsigned)&str + 4.

  parent reply	other threads:[~2023-05-11 11:36 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-09 16:48 [Bug c++/109791] New: " szhong at perforce dot com
2023-05-09 17:28 ` [Bug tree-optimization/109791] " pinskia at gcc dot gnu.org
2023-05-10  7:26 ` rguenth at gcc dot gnu.org
2023-05-11  8:05 ` aldyh at gcc dot gnu.org
2023-05-11  8:19 ` aldyh at gcc dot gnu.org
2023-05-11  9:39 ` rguenth at gcc dot gnu.org
2023-05-11  9:47 ` aldyh at gcc dot gnu.org
2023-05-11 11:36 ` rguenther at suse dot de [this message]
2023-05-11 11:40 ` rguenth at gcc dot gnu.org
2023-05-11 12:22 ` rguenth at gcc dot gnu.org
2023-05-11 12:34 ` rguenth at gcc dot gnu.org
2023-05-11 12:35 ` rguenth at gcc dot gnu.org
2023-05-11 12:36 ` rguenth at gcc dot gnu.org
2023-05-12 11:48 ` cvs-commit at gcc dot gnu.org
2023-05-25 12:14 ` rguenth at gcc dot gnu.org
2023-05-25 12:15 ` rguenth at gcc dot gnu.org
2023-05-25 12:16 ` rguenth at gcc dot gnu.org
2023-05-25 15:35 ` pinskia at gcc dot gnu.org
2023-06-07 22:28 ` 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-109791-4-5lTC0C97WO@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).