http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58041
--- Comment #9 from Martin Jambor <jamborm at gcc dot gnu.org> --- More specifically, if I am correct assuming that the MEM_REF replace_ref builds always accesses exactly the same memory as the previous access *expr does (and only the address is computed better) and that *expr is how the function accessed that memory before, then I think what you need is the following (untested, except that I know it seems to fix the testcase, at least the assembly looks very different :-) *** /tmp/heQHTs_gimple-ssa-strength-reduction.c Thu Aug 1 18:43:45 2013 --- gcc/gimple-ssa-strength-reduction.c Thu Aug 1 18:38:31 2013 *************** dump_incr_vec (void) *** 1728,1738 **** static void replace_ref (tree *expr, slsr_cand_t c) { ! tree add_expr = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (c->base_expr), ! c->base_expr, c->stride); ! tree mem_ref = fold_build2 (MEM_REF, TREE_TYPE (*expr), add_expr, ! double_int_to_tree (c->cand_type, c->index)); ! /* Gimplify the base addressing expression for the new MEM_REF tree. */ gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt); TREE_OPERAND (mem_ref, 0) --- 1728,1748 ---- static void replace_ref (tree *expr, slsr_cand_t c) { ! tree add_expr, mem_ref, acc_type = TREE_TYPE (*expr); ! unsigned HOST_WIDE_INT misalign; ! unsigned align; ! ! get_object_alignment_1 (*expr, &align, &misalign); ! if (misalign != 0) ! align = (misalign & -misalign); ! if (align < TYPE_ALIGN (acc_type)) ! acc_type = build_aligned_type (acc_type, align); ! ! add_expr = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (c->base_expr), ! c->base_expr, c->stride); ! mem_ref = fold_build2 (MEM_REF, acc_type, add_expr, ! double_int_to_tree (c->cand_type, c->index)); ! /* Gimplify the base addressing expression for the new MEM_REF tree. */ gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt); TREE_OPERAND (mem_ref, 0)