This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/23286] missed fully redundant expression
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 16 Feb 2012 12:44:31 +0000
- Subject: [Bug tree-optimization/23286] missed fully redundant expression
- Auto-submitted: auto-generated
- References: <bug-23286-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23286
--- Comment #38 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-02-16 12:44:31 UTC ---
Incremental patch to fix the EH related ICEs:
Index: gcc/tree-ssa-pre.c
===================================================================
--- gcc/tree-ssa-pre.c.orig 2012-02-16 12:08:57.000000000 +0100
+++ gcc/tree-ssa-pre.c 2012-02-16 12:08:50.000000000 +0100
@@ -3937,7 +3937,8 @@ do_hoist_insertion (basic_block block AT
find_or_generate_expression (block, expr, &stmts, NULL);
last = gsi_last_bb (block);
- if (gsi_end_p (last) || is_ctrl_stmt (gsi_stmt (last)))
+ if (gsi_end_p (last)
+ || stmt_ends_bb_p (gsi_stmt (last)))
gsi_insert_seq_before (&last, stmts, GSI_SAME_STMT);
else
gsi_insert_seq_after (&last, stmts, GSI_SAME_STMT);
when hoisting into
# BLOCK 19
# PRED: 18 (fallthru,exec)
[LP 15] D.2722_10 = CYapfBaseT::PfGetSettings (D.2723_9);
goto <bb 20>;
# SUCC: 20 (fallthru,exec) 113 (eh,exec)
but of course we'd have to verify we can hoist across such throwing
stmt (it might be a store clobbering what we insert),
so maybe disabling hoisting in that case would be more appropriate.
With
Index: gcc/tree-ssa-pre.c
===================================================================
--- gcc/tree-ssa-pre.c.orig 2012-02-16 12:28:04.000000000 +0100
+++ gcc/tree-ssa-pre.c 2012-02-16 12:27:37.000000000 +0100
@@ -3874,6 +3874,7 @@ do_hoist_insertion (basic_block block AT
bitmap_iterator bi;
bitmap_set_t hoistable_set;
bitmap availout_in_some;
+ gimple_stmt_iterator last;
/* At least two successors, or else... */
gcc_assert (EDGE_COUNT (block->succs) >= 2);
@@ -3886,6 +3887,14 @@ do_hoist_insertion (basic_block block AT
if (! single_pred_p (e->dest))
return false;
+ /* Determine the insertion point. If we cannot safely insert before
+ the last stmt if we'd have to, bail out. */
+ last = gsi_last_bb (block);
+ if (!gsi_end_p (last)
+ && !is_ctrl_stmt (gsi_stmt (last))
+ && stmt_ends_bb_p (gsi_stmt (last)))
+ return false;
+
hoistable_set = bitmap_set_new ();
availout_in_some = BITMAP_ALLOC (&grand_bitmap_obstack);
@@ -3916,7 +3925,6 @@ do_hoist_insertion (basic_block block AT
pre_expr expr = expression_for_id (i);
unsigned int value_id = get_expr_value_id (expr);
gimple_seq stmts = NULL;
- gimple_stmt_iterator last;
/* If the value of this expression is not available in at least one
successor, do not hoist the value. */
@@ -3936,7 +3944,6 @@ do_hoist_insertion (basic_block block AT
find_or_generate_expression (block, expr, &stmts, NULL);
- last = gsi_last_bb (block);
if (gsi_end_p (last) || is_ctrl_stmt (gsi_stmt (last)))
gsi_insert_seq_before (&last, stmts, GSI_SAME_STMT);
else
Which leaves us with
/abuild/rguenther/obj/./gcc/xgcc -B/abuild/rguenther/obj/./gcc/
-B/usr/local/x86_64-unknown-linux-gnu/bin/
-B/usr/local/x86_64-unknown-linux-gnu/lib/ -isystem
/usr/local/x86_64-unknown-linux-gnu/include -isystem
/usr/local/x86_64-unknown-linux-gnu/sys-include -c -g -O2 -m32 -fpic -W
-Wall -gnatpg -nostdinc -m32 a-nlrear.ads -o a-nlrear.o
raised STORAGE_ERROR : stack overflow or erroneous memory access
make[9]: *** [a-nlrear.o] Error 1
during stage3 libada build ...