The following fixes an old vectorizer issue with realignment support (thus only powerpc is affected) and BB vectorization. The realignment token is set up from the wrong data-ref which causes an SSA verification failure but in other circumstances might simply generate wrong code.
Bootstrap running on x86_64-unknown-linux-gnu, I'll install this as obvious on trunk. PPC folks - you know best how to appropriately test a target where we use the re-alignment optimization. IIRC on later powerpc hardware this isn't exercised at all since we can use unaligned accesses. The issue is at least present on the GCC 9 branch as well but I'd appreciate testing where it exercises the path before considering a backport. Thanks, Richard. 2019-09-17 Richard Biener <rguent...@suse.de> PR tree-optimization/91790 * tree-vect-stmts.c (vectorizable_load): For BB vectorization use the correct DR for setting up realignment. Index: gcc/tree-vect-stmts.c =================================================================== --- gcc/tree-vect-stmts.c (revision 275747) +++ gcc/tree-vect-stmts.c (working copy) @@ -9169,7 +9169,9 @@ vectorizable_load (stmt_vec_info stmt_in || alignment_support_scheme == dr_explicit_realign) && !compute_in_loop) { - msq = vect_setup_realignment (first_stmt_info, gsi, &realignment_token, + msq = vect_setup_realignment (first_stmt_info_for_drptr + ? first_stmt_info_for_drptr + : first_stmt_info, gsi, &realignment_token, alignment_support_scheme, NULL_TREE, &at_loop); if (alignment_support_scheme == dr_explicit_realign_optimized)