[backport from gcc-4.8/trunk r192322 ] gcc/ 2012-10-10 Jakub Jelinek PR tree-optimization/54877 * tree-vect-loop.c (vect_is_simple_reduction_1): For MINUS_EXPR use make_ssa_name instead of copy_ssa_name. gcc/testsuite/ 2012-10-10 Jakub Jelinek PR tree-optimization/54877 * gcc.dg/torture/pr54877.c: New test. --- gcc-4.7.2/gcc/testsuite/gcc.dg/torture/pr54877.c.~1~ 1970-01-01 01:00:00.000000000 +0100 +++ gcc-4.7.2/gcc/testsuite/gcc.dg/torture/pr54877.c 2012-10-13 10:28:06.000000000 +0200 @@ -0,0 +1,23 @@ +/* PR tree-optimization/54877 */ +/* { dg-do run } */ +/* { dg-options "-ffast-math" } */ + +extern void abort (void); + +int +foo (void) +{ + double d; + int i; + for (i = 0, d = 0; i < 64; i++) + d--; + return (int) d; +} + +int +main () +{ + if (foo () != -64) + abort (); + return 0; +} --- gcc-4.7.2/gcc/tree-vect-loop.c.~1~ 2012-08-06 16:34:27.000000000 +0200 +++ gcc-4.7.2/gcc/tree-vect-loop.c 2012-10-13 10:27:46.000000000 +0200 @@ -2257,7 +2257,7 @@ vect_is_simple_reduction_1 (loop_vec_inf if (orig_code == MINUS_EXPR) { tree rhs = gimple_assign_rhs2 (def_stmt); - tree negrhs = make_ssa_name (SSA_NAME_VAR (rhs), NULL); + tree negrhs = make_ssa_name (TREE_TYPE (rhs), NULL); gimple negate_stmt = gimple_build_assign_with_ops (NEGATE_EXPR, negrhs, rhs, NULL); gimple_stmt_iterator gsi = gsi_for_stmt (def_stmt);