https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117160
Bug ID: 117160
Summary: [15 regression] GCC trunk generates larger code than
GCC 14 at -Os/-Oz (progressed in 14)
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: dccitaliano at gmail dot com
Target Milestone: ---
https://godbolt.org/z/764Gs8Tvf
Inline code:
struct X {
int size;
char color;
};
int f(int a) {
X* p = new X();
p->size = a;
p->color = 'R';
for (int i = 0; i < p->size && (p->size % 2 == 0 || i < 5); i++) {
if (i > 2 && p->size > 10) {
p->size -= i;
} else {
p->size += i;
}
for (int j = 0; j < i && (p->size * j) % 3 == 0; j++) {
p->size += j * 2;
}
}
int result = p->size;
delete p;
return result;
}
Points to:
3e1bd6470e4deba1a3ad14621037098311ad1350 is the first bad commit
commit 3e1bd6470e4deba1a3ad14621037098311ad1350
Author: Richard Biener <[email protected]>
Date: Tue Oct 1 10:37:16 2024 +0200
tree-optimization/116906 - unsafe PRE with never executed edges
When we're computing ANTIC for PRE we treat edges to not yet visited
blocks as having a maximum ANTIC solution to get at an optimistic
solution in the iteration. That assumes the edges visted eventually
execute. This is a wrong assumption that can lead to wrong code
(and not only non-optimality) when possibly trapping expressions
are involved as the testcases in the PR show. The following mitigates
this by pruning trapping expressions from ANTIC computed when
maximum sets are involved.
PR tree-optimization/116906
* tree-ssa-pre.cc (prune_clobbered_mems): Add clean_traps
argument.
(compute_antic_aux): Direct prune_clobbered_mems to prune
all traps when any MAX solution was involved in the ANTIC
computation.
(compute_partial_antic_aux): Adjust.
* gcc.dg/pr116906-1.c: New testcase.
* gcc.dg/pr116906-2.c: Likewise.
gcc/testsuite/gcc.dg/pr116906-1.c | 43 +++++++++++++++++++++++++++++++++++++++
gcc/testsuite/gcc.dg/pr116906-2.c | 40 ++++++++++++++++++++++++++++++++++++
gcc/tree-ssa-pre.cc | 16 +++++++++------
3 files changed, 93 insertions(+), 6 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/pr116906-1.c
create mode 100644 gcc/testsuite/gcc.dg/pr116906-2.c
bisect found first bad commit