This fixes PR56778 - a fallout of my vectorizer TLC regarding dataref analysis. The patch restores a check that disallows runtime alias checks for gather loads (those are not loop invariant). It also fixes another possible source of issues.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied yesterday already (forget to post the patch ...). Richard. 2013-04-02 Richard Biener <rguent...@suse.de> PR tree-optimization/56778 * tree-vect-data-refs.c (vect_analyze_data_ref_dependence): Runtime alias tests are not supported for gather loads. * tree-vect-loop-manip.c (vect_loop_versioning): Insert stmts referenced from SSA operands before updating SSA form. * gcc.dg/torture/pr56778.c: New testcase. Index: gcc/tree-vect-data-refs.c =================================================================== *** gcc/tree-vect-data-refs.c (revision 197341) --- gcc/tree-vect-data-refs.c (working copy) *************** vect_analyze_data_ref_dependence (struct *** 280,285 **** --- 280,302 ---- /* Unknown data dependence. */ if (DDR_ARE_DEPENDENT (ddr) == chrec_dont_know) { + if (STMT_VINFO_GATHER_P (stmtinfo_a) + || STMT_VINFO_GATHER_P (stmtinfo_b)) + { + if (dump_enabled_p ()) + { + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "versioning for alias not supported for: " + "can't determine dependence between "); + dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, + DR_REF (dra)); + dump_printf (MSG_MISSED_OPTIMIZATION, " and "); + dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, + DR_REF (drb)); + } + return false; + } + if (dump_enabled_p ()) { dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, *************** vect_analyze_data_ref_dependence (struct *** 299,304 **** --- 316,338 ---- /* Known data dependence. */ if (DDR_NUM_DIST_VECTS (ddr) == 0) { + if (STMT_VINFO_GATHER_P (stmtinfo_a) + || STMT_VINFO_GATHER_P (stmtinfo_b)) + { + if (dump_enabled_p ()) + { + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "versioning for alias not supported for: " + "bad dist vector for "); + dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, + DR_REF (dra)); + dump_printf (MSG_MISSED_OPTIMIZATION, " and "); + dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, + DR_REF (drb)); + } + return false; + } + if (dump_enabled_p ()) { dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, Index: gcc/tree-vect-loop-manip.c =================================================================== *** gcc/tree-vect-loop-manip.c (revision 197341) --- gcc/tree-vect-loop-manip.c (working copy) *************** vect_loop_versioning (loop_vec_info loop *** 2476,2486 **** /* End loop-exit-fixes after versioning. */ - update_ssa (TODO_update_ssa); if (cond_expr_stmt_list) { cond_exp_gsi = gsi_last_bb (condition_bb); gsi_insert_seq_before (&cond_exp_gsi, cond_expr_stmt_list, GSI_SAME_STMT); } } --- 2476,2486 ---- /* End loop-exit-fixes after versioning. */ if (cond_expr_stmt_list) { cond_exp_gsi = gsi_last_bb (condition_bb); gsi_insert_seq_before (&cond_exp_gsi, cond_expr_stmt_list, GSI_SAME_STMT); } + update_ssa (TODO_update_ssa); } Index: gcc/testsuite/gcc.dg/torture/pr56778.c =================================================================== *** gcc/testsuite/gcc.dg/torture/pr56778.c (revision 0) --- gcc/testsuite/gcc.dg/torture/pr56778.c (working copy) *************** *** 0 **** --- 1,14 ---- + /* { dg-do compile } */ + + typedef struct { + float a,b,c; + } S; + + S * arr[100]; + + void bar (float *in[], int n) + { + int i; + for (i=0; i<n; i++) + (*in)[i] = -arr[i]->b; + }