From 36c5622ac8aca9636fb541d3689b9dd3ca9e0c27 Mon Sep 17 00:00:00 2001 From: jakub Date: Wed, 11 May 2011 13:07:54 +0000 Subject: [PATCH] PR debug/48159 * tree-ssa.c (reset_debug_uses): New function. * tree-flow.h (reset_debug_uses): New prototype. * tree-data-ref.c (stmts_from_loop): Ignore debug stmts. * tree-loop-distribution.c (generate_loops_for_partition): Call reset_debug_uses on the stmts that will be removed. Keep around all debug stmts, don't count them as bits in partition bitmap. (generate_builtin): Don't count debug stmts or labels as bits in partition bitmap. * gcc.dg/pr48159-1.c: New test. * gcc.dg/pr48159-2.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@173657 138bc75d-0d04-0410-961f-82ee72b054a4 index 3b64229..209b80b 100644 new file mode 100644 index 0000000..cd67e63 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr48159-1.c @@ -0,0 +1,10 @@ +/* PR debug/48159 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -fcompare-debug" } */ + +void +foo (double x, int y, double *__restrict z, double *__restrict w) +{ + while (y--) + *z++ = (*w++ = 0) * x; +} diff --git a/gcc/testsuite/gcc.dg/pr48159-2.c b/gcc/testsuite/gcc.dg/pr48159-2.c new file mode 100644 index 0000000..25596bf --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr48159-2.c @@ -0,0 +1,22 @@ +/* PR debug/48159 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-loop-distribution -fcompare-debug" } */ + +int foo (int * __restrict__ ia, int * __restrict__ ib, + int * __restrict__ oxa, int * __restrict__ oxb) +{ + int i; + int oya[52], oyb[52]; + for (i = 0; i < 52; i++) + { + int w1 = ia[i]; + int w2 = oxa[i]; + int w3 = ib[i]; + int w4 = oxb[i]; + int w5 = w1 + w2 + 5; + oya[i] = (w1 * w2) >> 10; + int w6 = w3 + w4 + 6; + oyb[i] = (w3 * w4) >> 10; + } + return oya[22] + oyb[21]; +} diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c index 54cb46c..39eab47 100644 --- a/gcc/tree-data-ref.c +++ b/gcc/tree-data-ref.c @@ -1,5 +1,5 @@ /* Data references and dependences detectors. - Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 + Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. Contributed by Sebastian Pop @@ -4975,7 +4975,7 @@ stmts_from_loop (struct loop *loop, VEC (gimple, heap) **stmts) for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi)) { stmt = gsi_stmt (bsi); - if (gimple_code (stmt) != GIMPLE_LABEL) + if (gimple_code (stmt) != GIMPLE_LABEL && !is_gimple_debug (stmt)) VEC_safe_push (gimple, heap, *stmts, stmt); } } diff --git a/gcc/tree-flow.h b/gcc/tree-flow.h index 14c8827..0777aec 100644 --- a/gcc/tree-flow.h +++ b/gcc/tree-flow.h @@ -559,6 +559,7 @@ extern void walk_use_def_chains (tree, walk_use_def_chains_fn, void *, bool); void insert_debug_temps_for_defs (gimple_stmt_iterator *); void insert_debug_temp_for_var_def (gimple_stmt_iterator *, tree); +void reset_debug_uses (gimple); void release_defs_bitset (bitmap toremove); /* In tree-into-ssa.c */ diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c index 5b147e3..1d6944e 100644 --- a/gcc/tree-loop-distribution.c +++ b/gcc/tree-loop-distribution.c @@ -1,5 +1,5 @@ /* Loop distribution. - Copyright (C) 2006, 2007, 2008, 2009, 2010 + Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. Contributed by Georges-Andre Silber and Sebastian Pop . @@ -181,6 +181,25 @@ generate_loops_for_partition (struct loop *loop, bitmap partition, bool copy_p) stmts_from_loop. */ bbs = get_loop_body_in_dom_order (loop); + if (MAY_HAVE_DEBUG_STMTS) + for (x = 0, i = 0; i < loop->num_nodes; i++) + { + basic_block bb = bbs[i]; + + for (bsi = gsi_start_phis (bb); !gsi_end_p (bsi); gsi_next (&bsi)) + if (!bitmap_bit_p (partition, x++)) + reset_debug_uses (gsi_stmt (bsi)); + + for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi)) + { + gimple stmt = gsi_stmt (bsi); + if (gimple_code (stmt) != GIMPLE_LABEL + && !is_gimple_debug (stmt) + && !bitmap_bit_p (partition, x++)) + reset_debug_uses (stmt); + } + } + for (x = 0, i = 0; i < loop->num_nodes; i++) { basic_block bb = bbs[i]; @@ -199,7 +218,8 @@ generate_loops_for_partition (struct loop *loop, bitmap partition, bool copy_p) for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi);) { gimple stmt = gsi_stmt (bsi); - if (gimple_code (gsi_stmt (bsi)) != GIMPLE_LABEL + if (gimple_code (stmt) != GIMPLE_LABEL + && !is_gimple_debug (stmt) && !bitmap_bit_p (partition, x++)) { unlink_stmt_vdef (stmt); @@ -312,7 +332,9 @@ generate_builtin (struct loop *loop, bitmap partition, bool copy_p) { gimple stmt = gsi_stmt (bsi); - if (bitmap_bit_p (partition, x++) + if (gimple_code (stmt) != GIMPLE_LABEL + && !is_gimple_debug (stmt) + && bitmap_bit_p (partition, x++) && is_gimple_assign (stmt) && !is_gimple_reg (gimple_assign_lhs (stmt))) { diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c index da6cc9b..0455680 100644 --- a/gcc/tree-ssa.c +++ b/gcc/tree-ssa.c @@ -507,6 +507,37 @@ insert_debug_temps_for_defs (gimple_stmt_iterator *gsi) } } +/* Reset all debug stmts that use SSA_NAME(s) defined in STMT. */ + +void +reset_debug_uses (gimple stmt) +{ + ssa_op_iter op_iter; + def_operand_p def_p; + imm_use_iterator imm_iter; + gimple use_stmt; + + if (!MAY_HAVE_DEBUG_STMTS) + return; + + FOR_EACH_PHI_OR_STMT_DEF (def_p, stmt, op_iter, SSA_OP_DEF) + { + tree var = DEF_FROM_PTR (def_p); + + if (TREE_CODE (var) != SSA_NAME) + continue; + + FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, var) + { + if (!gimple_debug_bind_p (use_stmt)) + continue; + + gimple_debug_bind_reset_value (use_stmt); + update_stmt (use_stmt); + } + } +} + /* Delete SSA DEFs for SSA versions in the TOREMOVE bitmap, removing dominated stmts before their dominators, so that release_ssa_defs stands a chance of propagating DEFs into debug bind stmts. */ -- 1.7.0.4