public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/112767] New: [14 regression] spurious -Waggressive-loop-optimizations @ 2023-11-29 18:24 sss@li-snyder.org 2023-11-29 18:34 ` [Bug tree-optimization/112767] " pinskia at gcc dot gnu.org ` (4 more replies) 0 siblings, 5 replies; 6+ messages in thread From: sss@li-snyder.org @ 2023-11-29 18:24 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112767 Bug ID: 112767 Summary: [14 regression] spurious -Waggressive-loop-optimizations Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: sss@li-snyder.org Target Milestone: --- With a recent checkout of gcc14 (20231129), on a x86_64-pc-linux-gnu host, the following source gives a seemingly bogus -Waggressive-loop-optimizations warning with -O3: -------------------------------------------------------------- double reg_dict[32]; void foo(int); void initialize() { int i=8; for (int phi=0; phi<8; ++phi) { reg_dict[i]=0; int sn = 0; if (i < 16) sn = 20; foo(sn); ++i; } } -------------------------------------------------------------- $ g++ -c -O3 x.cc x.cc: In function ‘void initialize()’: x.cc:9:16: warning: iteration 16 invokes undefined behavior [-Waggressive-loop-optimizations] 9 | reg_dict[i]=0; | ~~~~~~~~~~~^~ x.cc:8:22: note: within this loop 8 | for (int phi=0; phi<8; ++phi) { | ~~~^~ This is a confusing warning, as the containing loop is executed only 8 times. Exactly which undefined behavior is meant is also not spelled out. From the context, i'd guess it to be an out-of-bounds array write, but that's a false positive. The warning happens with -O3 but not with lower optimization levels. It also does not occur with gcc 13.2.1 20230728. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/112767] [14 regression] spurious -Waggressive-loop-optimizations 2023-11-29 18:24 [Bug c++/112767] New: [14 regression] spurious -Waggressive-loop-optimizations sss@li-snyder.org @ 2023-11-29 18:34 ` pinskia at gcc dot gnu.org 2023-11-29 22:08 ` ppalka at gcc dot gnu.org ` (3 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-11-29 18:34 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112767 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2023-11-29 Ever confirmed|0 |1 Target Milestone|--- |14.0 Status|UNCONFIRMED |NEW --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Confirmed. Looks like loop split is messing up ... ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/112767] [14 regression] spurious -Waggressive-loop-optimizations 2023-11-29 18:24 [Bug c++/112767] New: [14 regression] spurious -Waggressive-loop-optimizations sss@li-snyder.org 2023-11-29 18:34 ` [Bug tree-optimization/112767] " pinskia at gcc dot gnu.org @ 2023-11-29 22:08 ` ppalka at gcc dot gnu.org 2023-11-30 11:42 ` [Bug tree-optimization/112767] [14 regression] spurious -Waggressive-loop-optimizations since r14-2944-g3d48c11ad082de rguenth at gcc dot gnu.org ` (2 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: ppalka at gcc dot gnu.org @ 2023-11-29 22:08 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112767 Patrick Palka <ppalka at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ppalka at gcc dot gnu.org --- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> --- Started with r14-2944-g3d48c11ad082de ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/112767] [14 regression] spurious -Waggressive-loop-optimizations since r14-2944-g3d48c11ad082de 2023-11-29 18:24 [Bug c++/112767] New: [14 regression] spurious -Waggressive-loop-optimizations sss@li-snyder.org 2023-11-29 18:34 ` [Bug tree-optimization/112767] " pinskia at gcc dot gnu.org 2023-11-29 22:08 ` ppalka at gcc dot gnu.org @ 2023-11-30 11:42 ` rguenth at gcc dot gnu.org 2023-11-30 12:35 ` cvs-commit at gcc dot gnu.org 2023-11-30 12:36 ` rguenth at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: rguenth at gcc dot gnu.org @ 2023-11-30 11:42 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112767 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org Status|NEW |ASSIGNED --- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> --- Confirmed. Now with SCCP after loop splitting that's the pass exposing enough info but not eliding the loop before IVCANON comes and diagnoses this. SCCP does <bb 17> [local count: 119292719]: - # i_23 = PHI <i_8(3)> - # phi_24 = PHI <phi_9(3)> + i_23 = 16; + phi_24 = 8; if (phi_24 != 8) and only copyprop3 removes the condition. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/112767] [14 regression] spurious -Waggressive-loop-optimizations since r14-2944-g3d48c11ad082de 2023-11-29 18:24 [Bug c++/112767] New: [14 regression] spurious -Waggressive-loop-optimizations sss@li-snyder.org ` (2 preceding siblings ...) 2023-11-30 11:42 ` [Bug tree-optimization/112767] [14 regression] spurious -Waggressive-loop-optimizations since r14-2944-g3d48c11ad082de rguenth at gcc dot gnu.org @ 2023-11-30 12:35 ` cvs-commit at gcc dot gnu.org 2023-11-30 12:36 ` rguenth at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2023-11-30 12:35 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112767 --- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>: https://gcc.gnu.org/g:2dde9f326ded84814a78c3044294b535c1f97b41 commit r14-6010-g2dde9f326ded84814a78c3044294b535c1f97b41 Author: Richard Biener <rguenther@suse.de> Date: Thu Nov 30 12:38:53 2023 +0100 tree-optimization/112767 - spurious diagnostic after sccp/loop-split swap We are diagnosing an unreachable loop which we only manage to elide after the copyprop pass after sccp which leaves the code open for diagnosing by the intermittent ivcanon pass. The following makes sure to clean things up a bit earlier, propagating constant final values to uses immediately. PR tree-optimization/112767 * tree-scalar-evolution.cc (final_value_replacement_loop): Propagate constants to immediate uses immediately. * gcc.dg/tree-ssa/pr112767.c: New testcase. * gcc.dg/graphite/pr83255.c: Disable SCCP. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/112767] [14 regression] spurious -Waggressive-loop-optimizations since r14-2944-g3d48c11ad082de 2023-11-29 18:24 [Bug c++/112767] New: [14 regression] spurious -Waggressive-loop-optimizations sss@li-snyder.org ` (3 preceding siblings ...) 2023-11-30 12:35 ` cvs-commit at gcc dot gnu.org @ 2023-11-30 12:36 ` rguenth at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: rguenth at gcc dot gnu.org @ 2023-11-30 12:36 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112767 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |FIXED Status|ASSIGNED |RESOLVED --- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> --- Fixed. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-11-30 12:36 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-11-29 18:24 [Bug c++/112767] New: [14 regression] spurious -Waggressive-loop-optimizations sss@li-snyder.org 2023-11-29 18:34 ` [Bug tree-optimization/112767] " pinskia at gcc dot gnu.org 2023-11-29 22:08 ` ppalka at gcc dot gnu.org 2023-11-30 11:42 ` [Bug tree-optimization/112767] [14 regression] spurious -Waggressive-loop-optimizations since r14-2944-g3d48c11ad082de rguenth at gcc dot gnu.org 2023-11-30 12:35 ` cvs-commit at gcc dot gnu.org 2023-11-30 12:36 ` rguenth at gcc dot gnu.org
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).