Hi,
This fix the missing swap for stmt-to_insert. I tested this with the
attached test case which is not valid any more due to some other
commits. This I believe an is obvious fix and maybe the test case is
needed.
I am running bootstrap and regression testing on x86-64-linux gnu. Is
this OK for trunk if the testing is fine ?
Thanks,
Kugan
gcc/ChangeLog:
2016-05-28 Kugan Vivekanandarajah <[email protected]>
* tree-ssa-reassoc.c (swap_ops_for_binary_stmt): Fix swap such that
all fields including stmt_to_insert are swapped.
gcc/testsuite/ChangeLog:
2016-05-28 Kugan Vivekanandarajah <[email protected]>
* gcc.dg/tree-ssa/pr71252-2.c: New test.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr71252-2.c
b/gcc/testsuite/gcc.dg/tree-ssa/pr71252-2.c
index e69de29..e621d3e 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr71252-2.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr71252-2.c
@@ -0,0 +1,9 @@
+/* PR middle-end/71252 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+unsigned a;
+int b, c;
+void fn1 ()
+{
+ b = a + c + 3 + c;
+}
diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c
index c9ed679..d13be29 100644
--- a/gcc/tree-ssa-reassoc.c
+++ b/gcc/tree-ssa-reassoc.c
@@ -3763,25 +3763,13 @@ swap_ops_for_binary_stmt (vec<operand_entry *> ops,
|| (stmt && is_phi_for_stmt (stmt, oe3->op)
&& !is_phi_for_stmt (stmt, oe1->op)
&& !is_phi_for_stmt (stmt, oe2->op)))
- {
- operand_entry temp = *oe3;
- oe3->op = oe1->op;
- oe3->rank = oe1->rank;
- oe1->op = temp.op;
- oe1->rank= temp.rank;
- }
+ std::swap (*oe1, *oe3);
else if ((oe1->rank == oe3->rank
&& oe2->rank != oe3->rank)
|| (stmt && is_phi_for_stmt (stmt, oe2->op)
&& !is_phi_for_stmt (stmt, oe1->op)
&& !is_phi_for_stmt (stmt, oe3->op)))
- {
- operand_entry temp = *oe2;
- oe2->op = oe1->op;
- oe2->rank = oe1->rank;
- oe1->op = temp.op;
- oe1->rank = temp.rank;
- }
+ std::swap (*oe1, *oe3);
}
/* If definition of RHS1 or RHS2 dominates STMT, return the later of those