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 libstdc++/110807] [13/14 Regression] Copy list initialisation of a vector<bool> raises a warning with -O2
Date: Wed, 26 Jul 2023 07:43:42 +0000	[thread overview]
Message-ID: <bug-110807-4-LRAbbZ8VU3@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-110807-4@http.gcc.gnu.org/bugzilla/>

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
          Component|tree-optimization           |libstdc++
      Known to fail|                            |14.0
   Last reconfirmed|                            |2023-07-26
           Keywords|                            |missed-optimization
             Status|UNCONFIRMED                 |NEW

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  We're diagnosing the sequence

<bb 2> [local count: 1073741824]:
D.26106[0] = 1;
_7 = byCallSpread.D.26008._M_impl.D.25481._M_start.D.16802._M_p;
_8 = MEM[(const struct _Bit_iterator &)&byCallSpread + 16].D.16802._M_offset;
_9 = MEM[(const struct _Bit_iterator &)&byCallSpread + 16].D.16802._M_p;
_10 = _9 - _7;
_11 = _10 * 8;
_12 = (long int) _8;
_13 = _11 + _12;
_14 = (long unsigned int) _13;
if (_14 > 1)
  goto <bb 3>; [50.00%]
else
  goto <bb 4>; [50.00%]

<bb 4> [local count: 536870913]:
if (_13 == 1)
  goto <bb 5>; [89.00%]
else
  goto <bb 9>; [11.00%]

<bb 9> [local count: 375809640]:
__result ={v} {CLOBBER(eol)};
_118 = MEM[(const struct _Bvector_impl
*)&byCallSpread].D.25481._M_end_of_storage;
if (_7 != _118)
  goto <bb 10>; [50.00%]
else
  goto <bb 14>; [50.00%]

<bb 14> [local count: 187904820]:
_316 = operator new (8);
_138 = byCallSpread.D.26008._M_impl.D.25481._M_start.D.16802._M_p;
_339 = _9 - _138;
_775 = (long unsigned int) _339;
if (_339 > 8)
  goto <bb 15>; [90.00%]
else
  goto <bb 16>; [10.00%]

<bb 15> [local count: 169114338]:
__builtin_memmove (_316, _138, _775);

the memmove call in BB 15 is diagnosed, it goes to storage of size 8
and obviously the guarding test just checked we will write more than 8 bytes
here.

I'm just guessing this is a missed optimization (this code must be
unreachable), but possibly again the standard library implementation
might make it impossible for the compiler to prove that given it isn't
able to second-guess constraints in the standard library.
Disclaimer: I didn't try to decipher the shitload of code we generate for
this simple function ;)

  parent reply	other threads:[~2023-07-26  7:43 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-25 18:26 [Bug c++/110807] New: " twic at urchin dot earth.li
2023-07-26  6:30 ` [Bug tree-optimization/110807] " pinskia at gcc dot gnu.org
2023-07-26  6:32 ` [Bug tree-optimization/110807] [13/14 Regression] " pinskia at gcc dot gnu.org
2023-07-26  7:43 ` rguenth at gcc dot gnu.org [this message]
2023-07-26 12:04 ` [Bug libstdc++/110807] " redi at gcc dot gnu.org
2023-07-26 13:34 ` redi at gcc dot gnu.org
2023-07-26 13:34 ` redi at gcc dot gnu.org
2023-07-26 16:02 ` cvs-commit at gcc dot gnu.org
2023-07-26 16:04 ` [Bug libstdc++/110807] [13 " redi at gcc dot gnu.org
2023-07-26 18:11 ` cvs-commit at gcc dot gnu.org
2023-07-28 10:13 ` redi at gcc dot gnu.org
2023-07-28 17:32 ` cvs-commit at gcc dot gnu.org
2023-07-28 19:00 ` redi at gcc dot gnu.org
2023-11-06 12:20 ` aoliva at gcc dot gnu.org
2023-11-06 12:38 ` redi at gcc dot gnu.org
2023-11-09  3:30 ` cvs-commit at gcc dot gnu.org
2024-02-09  8:46 ` cvs-commit 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-110807-4-LRAbbZ8VU3@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).