This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR71352
- From: Richard Biener <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 31 May 2016 14:13:51 +0200 (CEST)
- Subject: [PATCH] Fix PR71352
- Authentication-results: sourceware.org; auth=none
The following fixes another fallout of the negate multiply reassoc patch.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.
Richard.
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.
Index: gcc/tree-ssa-reassoc.c
===================================================================
*** gcc/tree-ssa-reassoc.c (revision 236877)
--- gcc/tree-ssa-reassoc.c (working copy)
*************** zero_one_operation (tree *def, enum tree
*** 1199,1209 ****
propagate_op_to_single_use (op, stmt, def);
return;
}
! else if (gimple_assign_rhs_code (stmt) == NEGATE_EXPR
! && gimple_assign_rhs1 (stmt) == op)
{
! propagate_op_to_single_use (op, stmt, def);
! return;
}
}
--- 1199,1218 ----
propagate_op_to_single_use (op, stmt, def);
return;
}
! else if (gimple_assign_rhs_code (stmt) == NEGATE_EXPR)
{
! 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;
! }
}
}
*************** zero_one_operation (tree *def, enum tree
*** 1238,1248 ****
return;
}
else if (is_gimple_assign (stmt2)
! && gimple_assign_rhs_code (stmt2) == NEGATE_EXPR
! && gimple_assign_rhs1 (stmt2) == op)
{
! propagate_op_to_single_use (op, stmt2, def);
! return;
}
}
--- 1247,1266 ----
return;
}
else if (is_gimple_assign (stmt2)
! && gimple_assign_rhs_code (stmt2) == NEGATE_EXPR)
{
! 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;
! }
}
}
Index: gcc/testsuite/gcc.dg/tree-ssa/reassoc-45.c
===================================================================
*** gcc/testsuite/gcc.dg/tree-ssa/reassoc-45.c (revision 0)
--- gcc/testsuite/gcc.dg/tree-ssa/reassoc-45.c (working copy)
***************
*** 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" } } */