[PATCH] Alternative fix for PR46172
Richard Guenther
rguenther@suse.de
Thu Nov 18 14:31:00 GMT 2010
This fixes the ICE occuring with dead vectorizer pattern stmts
during expand. A proper fix is of course to rework the vectorizer
to not require the pattern stmts in the first place.
Bootstrap and regtest pending.
Richard.
2010-11-18 Richard Guenther <rguenther@suse.de>
PR tree-optimization/46172
* tree-vect-loop-manip.c (remove_dead_stmts_from_loop): New
function.
(slpeel_tree_peel_loop_to_edge): Call it.
* gcc.dg/torture/pr46172.c: New testcase.
Index: gcc/tree-vect-loop-manip.c
===================================================================
*** gcc/tree-vect-loop-manip.c (revision 166902)
--- gcc/tree-vect-loop-manip.c (working copy)
*************** set_prologue_iterations (basic_block bb_
*** 1107,1112 ****
--- 1107,1140 ----
}
+ /* Remove dead assignments from loop NEW_LOOP. */
+
+ static void
+ remove_dead_stmts_from_loop (struct loop *new_loop)
+ {
+ basic_block *bbs = get_loop_body (new_loop);
+ unsigned i;
+ for (i = 0; i < new_loop->num_nodes; ++i)
+ {
+ gimple_stmt_iterator gsi;
+ for (gsi = gsi_start_bb (bbs[i]); !gsi_end_p (gsi);)
+ {
+ gimple stmt = gsi_stmt (gsi);
+ if (is_gimple_assign (stmt)
+ && TREE_CODE (gimple_assign_lhs (stmt)) == SSA_NAME
+ && has_zero_uses (gimple_assign_lhs (stmt)))
+ {
+ gsi_remove (&gsi, true);
+ release_defs (stmt);
+ }
+ else
+ gsi_next (&gsi);
+ }
+ }
+ free (bbs);
+ }
+
+
/* Function slpeel_tree_peel_loop_to_edge.
Peel the first (last) iterations of LOOP into a new prolog (epilog) loop
*************** slpeel_tree_peel_loop_to_edge (struct lo
*** 1237,1242 ****
--- 1265,1276 ----
slpeel_update_phis_for_duplicate_loop (loop, new_loop, e == exit_e);
rename_variables_in_loop (new_loop);
+ /* Remove all pattern statements from the loop copy. They will confuse
+ the expander if DCE is disabled.
+ ??? The pattern recognizer should be split into an analysis and
+ a transformation phase that is then run only on the loop that is
+ going to be transformed. */
+ remove_dead_stmts_from_loop (new_loop);
/* 2. Add the guard code in one of the following ways:
Index: gcc/testsuite/gcc.dg/torture/pr46172.c
===================================================================
*** gcc/testsuite/gcc.dg/torture/pr46172.c (revision 0)
--- gcc/testsuite/gcc.dg/torture/pr46172.c (revision 0)
***************
*** 0 ****
--- 1,13 ----
+ /* { dg-do compile } */
+ /* { dg-options "-fno-tree-dce -ftree-vectorize" } */
+
+ extern short X[];
+
+ int foo (int len)
+ {
+ int i;
+ int s = 0;
+ for (i = 0; i < len; i++)
+ s += X[i] * X[i];
+ return s;
+ }
More information about the Gcc-patches
mailing list