This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix predcom ICE introduced by var clobber changes (PR tree-optimization/51246, take 2)
On Thu, Nov 24, 2011 at 05:28:00PM +0100, Michael Matz wrote:
> As the default defs are already automatically handled by all our ssa
> infrastructure (including warning and propagation machinery) I think it
> would be best to generate such one instead of a clobber for the RHS.
So like this?
2011-11-24 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/51246
* tree-predcom.c (replace_ref_with): Handle also clobber on the
rhs.
* gcc.c-torture/compile/pr51246.c: New test.
--- gcc/tree-predcom.c.jj 2011-09-26 14:07:06.000000000 +0200
+++ gcc/tree-predcom.c 2011-11-24 17:39:08.196727939 +0100
@@ -1306,8 +1306,20 @@ replace_ref_with (gimple stmt, tree new_
val = gimple_assign_lhs (stmt);
if (TREE_CODE (val) != SSA_NAME)
{
- gcc_assert (gimple_assign_copy_p (stmt));
val = gimple_assign_rhs1 (stmt);
+ gcc_assert (gimple_assign_single_p (stmt));
+ if (TREE_CLOBBER_P (val))
+ {
+ val = gimple_default_def (cfun, SSA_NAME_VAR (new_tree));
+ if (val == NULL_TREE)
+ {
+ val = make_ssa_name (SSA_NAME_VAR (new_tree),
+ gimple_build_nop ());
+ set_default_def (SSA_NAME_VAR (new_tree), val);
+ }
+ }
+ else
+ gcc_assert (gimple_assign_copy_p (stmt));
}
}
else
--- gcc/testsuite/gcc.c-torture/compile/pr51246.c.jj 2011-11-24 09:15:10.322906812 +0100
+++ gcc/testsuite/gcc.c-torture/compile/pr51246.c 2011-11-24 09:14:52.000000000 +0100
@@ -0,0 +1,14 @@
+/* PR tree-optimization/51246 */
+
+int a, *b;
+
+void
+test (void)
+{
+ while (1)
+ {
+ int c;
+ a = c;
+ b = &c;
+ }
+}
Jakub