diff mbox

Fix MINUS_EXPR vect reduction handling (PR tree-optimization/54877)

Message ID 20121010174752.GZ26735@tucnak.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Oct. 10, 2012, 5:47 p.m. UTC
On Wed, Oct 10, 2012 at 10:42:10AM +0200, Richard Biener wrote:
> Ah, no, make_ssa_name (TREE_TYPE (rhs), NULL) is even better.  On
> the 4.7 branch you need to create a new temp var ...

Ok, here is what I've committed to trunk after bootstrap/regtest:

2012-10-10  Jakub Jelinek  <jakub@redhat.com>

	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.dg/torture/pr54877.c: New test.


	Jakub
diff mbox

Patch

--- gcc/tree-vect-loop.c.jj	2012-10-05 13:21:22.000000000 +0200
+++ gcc/tree-vect-loop.c	2012-10-10 11:46:17.798891846 +0200
@@ -2382,7 +2382,7 @@  vect_is_simple_reduction_1 (loop_vec_inf
   if (orig_code == MINUS_EXPR)
     {
       tree rhs = gimple_assign_rhs2 (def_stmt);
-      tree negrhs = copy_ssa_name (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);
--- gcc/testsuite/gcc.dg/torture/pr54877.c.jj	2012-10-09 20:50:43.083259039 +0200
+++ gcc/testsuite/gcc.dg/torture/pr54877.c	2012-10-09 20:51:40.463941703 +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;
+}