Hi! If gsi_stmt (*gsi) is a debug stmt, vect_finish_stmt_generation happily copies over location from the debug stmt, instead of the following non-debug stmt, which causes -fcompare-debug failures.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2011-08-18 Jakub Jelinek <ja...@redhat.com> PR debug/50017 * tree-vect-stmts.c (vect_finish_stmt_generation): If gsi_stmt (*gsi) is a debug stmt, use location of the first non-debug stmt after it. * gcc.dg/pr50017.c: New test. --- gcc/tree-vect-stmts.c.jj 2011-08-18 08:36:00.000000000 +0200 +++ gcc/tree-vect-stmts.c 2011-08-18 09:53:40.000000000 +0200 @@ -1,5 +1,5 @@ /* Statement Analysis and Transformation for Vectorization - 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 Dorit Naishlos <do...@il.ibm.com> and Ira Rosen <i...@il.ibm.com> @@ -1419,6 +1419,7 @@ vect_finish_stmt_generation (gimple stmt stmt_vec_info stmt_info = vinfo_for_stmt (stmt); loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_info); bb_vec_info bb_vinfo = STMT_VINFO_BB_VINFO (stmt_info); + gimple_stmt_iterator si; gcc_assert (gimple_code (stmt) != GIMPLE_LABEL); @@ -1433,7 +1434,13 @@ vect_finish_stmt_generation (gimple stmt print_gimple_stmt (vect_dump, vec_stmt, 0, TDF_SLIM); } - gimple_set_location (vec_stmt, gimple_location (gsi_stmt (*gsi))); + si = *gsi; + if (is_gimple_debug (gsi_stmt (si))) + { + gsi_next_nondebug (&si); + gcc_assert (!gsi_end_p (si)); + } + gimple_set_location (vec_stmt, gimple_location (gsi_stmt (si))); } /* Checks if CALL can be vectorized in type VECTYPE. Returns --- gcc/testsuite/gcc.dg/pr50017.c.jj 2011-08-18 09:59:58.000000000 +0200 +++ gcc/testsuite/gcc.dg/pr50017.c 2011-08-18 09:59:19.000000000 +0200 @@ -0,0 +1,20 @@ +/* PR debug/50017 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -fcompare-debug" } */ + +struct S { int r, i; }; + +void +foo (struct S *x, int y) +{ + int i; + for (i = 1; i < y; i++) + { + struct S a, b, c; + a = x[0]; + b = x[i]; + c.r = a.r * b.r - a.i * b.i; + c.i = a.r * b.i + a.i * b.r; + x[i] = c; + } +} Jakub