From ef13324ecab94740e5bb2f4c65e0600fe616e9ae Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Wed, 16 Mar 2011 12:41:08 +0000 Subject: [PATCH] re PR c/48146 (ICE tree check: expected ssa_name, have var_decl in has_zero_uses, at tree-flow-inline.h:342) 2011-03-16 Richard Guenther PR tree-optimization/48146 * tree-ssa-sink.c (sink_code_in_bb): Manually update virtual operands avoiding the need for renaming. * gcc.dg/torture/pr48146.c: New testcase. From-SVN: r171045 --- gcc/ChangeLog | 6 +++++ gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/gcc.dg/torture/pr48146.c | 35 ++++++++++++++++++++++++++ gcc/tree-ssa-sink.c | 14 ++++++++--- 4 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr48146.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f42547c88fb..7e81a550dfb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2011-03-16 Richard Guenther + + PR tree-optimization/48146 + * tree-ssa-sink.c (sink_code_in_bb): Manually update virtual + operands avoiding the need for renaming. + 2011-03-16 Richard Guenther * gimple-fold.c (maybe_fold_reference): Open-code relevant diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b3d5f8193fd..2e6963b0460 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-03-16 Richard Guenther + + PR tree-optimization/48146 + * gcc.dg/torture/pr48146.c: New testcase. + 2011-03-16 Richard Guenther * gcc.dg/tree-ssa/pr14814.c: Adjust. diff --git a/gcc/testsuite/gcc.dg/torture/pr48146.c b/gcc/testsuite/gcc.dg/torture/pr48146.c new file mode 100644 index 00000000000..c208325311c --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr48146.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ + +static unsigned char +safe_sub_func_int_s_s (int si1, unsigned char si2) +{ + return si1 ^ si2 & -si2 ^ si2 ? : si1 - si2; +} + +int g_2[10] = { + 0x90AC204EL +}; + +volatile unsigned char g_39; + +unsigned char +func_67 (unsigned short p_68) +{ + unsigned char l_92; + unsigned char l_74; + int *l = &g_2[6]; +lbl_90:*l ^= 1; + if (p_68) + goto lbl_93; + for (l_74 = 0;; l_74 = safe_sub_func_int_s_s (l_74, 1)) + { + if (l_74) + goto lbl_90; +lbl_93:l_92 ^= 0 != &g_39; + if (0) + { + } + else + *l = 1; + } +} diff --git a/gcc/tree-ssa-sink.c b/gcc/tree-ssa-sink.c index c3119ba5a70..4dc5ae44a27 100644 --- a/gcc/tree-ssa-sink.c +++ b/gcc/tree-ssa-sink.c @@ -505,12 +505,18 @@ sink_code_in_bb (basic_block bb) bb->index, (gsi_bb (togsi))->index); } - /* Prepare for VOP update. */ + /* Update virtual operands of statements in the path we + do not sink to. */ if (gimple_vdef (stmt)) { - unlink_stmt_vdef (stmt); - gimple_set_vdef (stmt, gimple_vop (cfun)); - mark_sym_for_renaming (gimple_vop (cfun)); + imm_use_iterator iter; + use_operand_p use_p; + gimple vuse_stmt; + + FOR_EACH_IMM_USE_STMT (vuse_stmt, iter, gimple_vdef (stmt)) + if (gimple_code (vuse_stmt) != GIMPLE_PHI) + FOR_EACH_IMM_USE_ON_STMT (use_p, iter) + SET_USE (use_p, gimple_vuse (stmt)); } /* If this is the end of the basic block, we need to insert at the end -- 2.30.2