http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60930
--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> --- I think the problem is that we look at expressions in 'long unsigned int' but a base_cand of type 'int'. That is, the bug in the computation is that ctype is unsigned long but stride is int. If that is really desired and required then you want to do sth more like Index: gcc/gimple-ssa-strength-reduction.c =================================================================== --- gcc/gimple-ssa-strength-reduction.c (revision 209677) +++ gcc/gimple-ssa-strength-reduction.c (working copy) @@ -1114,15 +1114,20 @@ create_mul_imm_cand (gimple gs, tree bas X = Y * c ============================ X = (B + i') * (S * c) */ - base = base_cand->base_expr; - index = base_cand->index; temp = tree_to_double_int (base_cand->stride) * tree_to_double_int (stride_in); - stride = double_int_to_tree (TREE_TYPE (stride_in), temp); - ctype = base_cand->cand_type; - if (has_single_use (base_in)) - savings = (base_cand->dead_savings - + stmt_cost (base_cand->cand_stmt, speed)); + temp = temp.ext (TYPE_PRECISION (base_cand->cand_type), + TYPE_UNSIGNED (base_cand->cand_type)); + if (double_int_fits_to_tree_p (TREE_TYPE (stride_in), temp)) + { + base = base_cand->base_expr; + index = base_cand->index; + stride = double_int_to_tree (TREE_TYPE (stride_in), temp); + ctype = base_cand->cand_type; + if (has_single_use (base_in)) + savings = (base_cand->dead_savings + + stmt_cost (base_cand->cand_stmt, speed)); + } } else if (base_cand->kind == CAND_ADD && integer_onep (base_cand->stride)) { as I suppose a truncation to ctype will happen anyway (and is ok).