This fixes PR54981, loop distribution was depending on DEBUG_STMT uses. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
Richard. 2012-10-19 Richard Guenther <rguent...@suse.de> PR tree-optimization/54981 * tree-loop-distribution.c (ssa_name_has_uses_outside_loop_p): Do not consider debug stmts as uses. * gcc.dg/pr54981.c: New testcase. Index: gcc/tree-loop-distribution.c =================================================================== *** gcc/tree-loop-distribution.c (revision 192560) --- gcc/tree-loop-distribution.c (working copy) *************** ssa_name_has_uses_outside_loop_p (tree d *** 125,132 **** use_operand_p use_p; FOR_EACH_IMM_USE_FAST (use_p, imm_iter, def) ! if (loop != loop_containing_stmt (USE_STMT (use_p))) ! return true; return false; } --- 125,136 ---- use_operand_p use_p; FOR_EACH_IMM_USE_FAST (use_p, imm_iter, def) ! { ! gimple use_stmt = USE_STMT (use_p); ! if (!is_gimple_debug (use_stmt) ! && loop != loop_containing_stmt (use_stmt)) ! return true; ! } return false; } Index: gcc/testsuite/gcc.dg/pr54981.c =================================================================== *** gcc/testsuite/gcc.dg/pr54981.c (revision 0) --- gcc/testsuite/gcc.dg/pr54981.c (working copy) *************** *** 0 **** --- 1,15 ---- + /* { dg-do compile } */ + /* { dg-options "-O -ftree-loop-distribute-patterns -fcompare-debug" } */ + + extern void bar(unsigned *, char *); + + void foo(char *s) + { + unsigned i; + char t[2]; + + bar(&i, t); + + for (i = 0; i < 2; i++) + s[i] = t[i]; + }