public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/113239] [13/14 regression] After 822a11a1e64, bogus -Warray-bounds warnings in std::vector Date: Sun, 21 Jan 2024 01:44:25 +0000 [thread overview] Message-ID: <bug-113239-4-u1wIYCrrne@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-113239-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113239 --- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Note the missed optimization was there in GCC 12, just the diagnostic was not. We have: ``` _4 = MEM[(const unsigned char * const &)current_frame__2(D) + 24]; _7 = MEM[(const unsigned char * const &)current_frame__2(D) + 16]; if (_4 == _7) goto <bb 3>; [17.43%] else goto <bb 6>; [82.57%] <bb 3> [local count: 187153200]: ... MEM <vector(2) long unsigned int> [(unsigned char * *)_5(D) + 16B] = { 0, 0 }; MEM[(struct _Vector_base *)_5(D) + 16B]._M_impl.D.21112._M_end_of_storage = 0B; _21 = MEM[(const unsigned char * const &)current_frame__2(D) + 24]; _22 = MEM[(const unsigned char * const &)current_frame__2(D) + 16]; _Num_23 = _21 - _22; ``` But based on the original condition (and the stores to offset of _5 [which technically cannot alias current_frame__2]), _Num_23 will be 0. What g:822a11a1e642e0abe92a996e7033a5066905a447 does is just add an extra if statement where we get: ``` if (_Num_24 > 1) goto <bb 4>; [90.00%] else goto <bb 5>; [10.00%] <bb 4> [local count: 156478790]: _Num.5_28 = (long unsigned int) _Num_24; __builtin_memmove (0B, _22, _Num.5_28); goto <bb 7>; [100.00%] <bb 5> [local count: 17386533]: if (_Num_24 == 1) goto <bb 6>; [34.00%] else goto <bb 7>; [66.00%] <bb 6> [local count: 5911421]: MEM[(unsigned char *)0B] ={v} 0; /// <<<<<< This is causing the warning __builtin_trap (); ``` Instead of just: ``` if (_Num_23 != 0) goto <bb 4>; [33.00%] else goto <bb 5>; [67.00%] <bb 4> [local count: 57375556]: _Num.4_24 = (long unsigned int) _Num_23; __builtin_memmove (0B, _22, _Num.4_24); ```
next prev parent reply other threads:[~2024-01-21 1:44 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-01-04 20:45 [Bug c++/113239] New: [13 " dimitry@unified-streaming.com 2024-01-04 21:10 ` [Bug tree-optimization/113239] " pinskia at gcc dot gnu.org 2024-01-06 22:49 ` dimitry@unified-streaming.com 2024-01-06 22:53 ` dimitry@unified-streaming.com 2024-01-08 14:57 ` [Bug tree-optimization/113239] [13/14 " rguenth at gcc dot gnu.org 2024-01-21 1:44 ` pinskia at gcc dot gnu.org [this message] 2024-01-21 1:46 ` pinskia at gcc dot gnu.org 2024-01-22 16:05 ` fche at redhat dot com 2024-01-22 16:34 ` dimitry@unified-streaming.com 2024-03-07 20:52 ` law at gcc dot gnu.org 2024-05-21 9:18 ` [Bug tree-optimization/113239] [13/14/15 " jakub 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-113239-4-u1wIYCrrne@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: linkBe 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).