https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80032
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
CC| |jakub at gcc dot gnu.org
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
The clobbers are on paths founds dead by DCE. We basically have
if (cleanup)
D.2369 ={v} {CLOBBER;}
which, given the clobber isn't really "necessary", gets completely removed.
We can't simply promote the clobber to happen unconditionally. Simply leaving
the conditional around like with
Index: gcc/tree-ssa-dce.c
===================================================================
--- gcc/tree-ssa-dce.c (revision 246082)
+++ gcc/tree-ssa-dce.c (working copy)
@@ -182,6 +182,8 @@ mark_operand_necessary (tree op)
worklist.safe_push (stmt);
}
+static void
+mark_control_dependent_edges_necessary (basic_block bb, bool ignore_self);
/* Mark STMT as necessary if it obviously is. Add it to the worklist if
it can make other statements necessary.
@@ -277,7 +279,11 @@ mark_stmt_if_obviously_necessary (gimple
case GIMPLE_ASSIGN:
if (gimple_clobber_p (stmt))
- return;
+ {
+ if (aggressive)
+ mark_control_dependent_edges_necessary (gimple_bb (stmt), true);
+ return;
+ }
break;
default:
results in us eventually doing the clobber unconditionally anyway through
threading and we generate larger code:
> g++-7 -c t.ii -O2
> size t.o
text data bss dec hex filename
1384 0 0 1384 568 t.o
> g++-7 -c t.ii -O2 -B.
> size t.o
text data bss dec hex filename
1479 0 0 1479 5c7 t.o
but
> g++-7 -c t.ii -O2 -B. -fstack-usage -Wstack-usage=96
t.ii: In function ‘void test::FN(test::db::ManagedObject&, const
test::BitMask&’:
t.ii:31:6: warning: stack usage is 112 bytes [-Wstack-usage=]
void FN(ManagedObject &k, const BitMask &) {
^~
which is a bit closer to the 96 bytes needed with gcc5 (which needed a text
size of only 1097 bytes btw, GCC 6 needs 1231 bytes). With -Os and the patch
trunk needs 80 bytes stack and 1379 bytes text.
I think w/o the threading happening we cannot optimize stack usage later.
Jakub, any opinion on the above patch?