re PR tree-optimization/71352 (ICE at -O1 and above on x86_64-linux-gnu: in zero_one_...
authorRichard Biener <rguenther@suse.de>
Tue, 31 May 2016 12:18:15 +0000 (12:18 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 31 May 2016 12:18:15 +0000 (12:18 +0000)
2016-05-31  Richard Biener  <rguenther@suse.de>

PR tree-optimization/71352
* tree-ssa-reassoc.c (zero_one_operation): Handle op equal to
minus one and a negate.

* gcc.dg/tree-ssa/reassoc-45.c: New testcase.

From-SVN: r236920

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/reassoc-45.c [new file with mode: 0644]
gcc/tree-ssa-reassoc.c

index ae81bbfb1a995b24b9ae731bd731637547f9240e..41bb494ec551636e8cdc2f743272367413a46b6d 100644 (file)
@@ -1,3 +1,9 @@
+2016-05-31  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/71352
+       * tree-ssa-reassoc.c (zero_one_operation): Handle op equal to
+       minus one and a negate.
+
 2016-05-31  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
 
        * config/aarch64/aarch64.c (aarch64_simd_attr_length_move): Delete.
index 563d5e5885ca25777805c72bb108e8b958db603f..8c5def43270ec9c8e5a4c1d4978fa5ae8e46f26d 100644 (file)
@@ -1,3 +1,8 @@
+2016-05-31  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/71352
+       * gcc.dg/tree-ssa/reassoc-45.c: New testcase.
+
 2016-05-31  Thomas Preud'homme  <thomas.preudhomme@arm.com>
 
        * gcc.target/arm/armv5_thumb_isa.c: New test.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-45.c b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-45.c
new file mode 100644 (file)
index 0000000..48f6b74
--- /dev/null
@@ -0,0 +1,15 @@
+/* PR/71352 */
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-reassoc1" } */
+
+unsigned a, b, c, d, e;
+
+void
+fn1 ()
+{
+  unsigned f;
+  e = f = d * -b + a * -c;
+}
+
+/* Check that we factor -1 and create -(d * b + a * c).  */
+/* { dg-final { scan-tree-dump-times " = -" 1 "reassoc1" } } */
index 430bcc8eb40ca2fee5d6053b3eac85986afa7659..1973077db7cb6682e80908029418c4faccb9ce2a 100644 (file)
@@ -1199,11 +1199,20 @@ zero_one_operation (tree *def, enum tree_code opcode, tree op)
                propagate_op_to_single_use (op, stmt, def);
              return;
            }
-         else if (gimple_assign_rhs_code (stmt) == NEGATE_EXPR
-                  && gimple_assign_rhs1 (stmt) == op)
+         else if (gimple_assign_rhs_code (stmt) == NEGATE_EXPR)
            {
-             propagate_op_to_single_use (op, stmt, def);
-             return;
+             if (gimple_assign_rhs1 (stmt) == op)
+               {
+                 propagate_op_to_single_use (op, stmt, def);
+                 return;
+               }
+             else if (integer_minus_onep (op)
+                      || real_minus_onep (op))
+               {
+                 gimple_assign_set_rhs_code
+                   (stmt, TREE_CODE (gimple_assign_rhs1 (stmt)));
+                 return;
+               }
            }
        }
 
@@ -1238,11 +1247,20 @@ zero_one_operation (tree *def, enum tree_code opcode, tree op)
              return;
            }
          else if (is_gimple_assign (stmt2)
-                  && gimple_assign_rhs_code (stmt2) == NEGATE_EXPR
-                  && gimple_assign_rhs1 (stmt2) == op)
+                  && gimple_assign_rhs_code (stmt2) == NEGATE_EXPR)
            {
-             propagate_op_to_single_use (op, stmt2, def);
-             return;
+             if (gimple_assign_rhs1 (stmt2) == op)
+               {
+                 propagate_op_to_single_use (op, stmt2, def);
+                 return;
+               }
+             else if (integer_minus_onep (op)
+                      || real_minus_onep (op))
+               {
+                 gimple_assign_set_rhs_code
+                   (stmt2, TREE_CODE (gimple_assign_rhs1 (stmt2)));
+                 return;
+               }
            }
        }