From db5447cad85ddee2973bc95cb5d4890b8c3d847b Mon Sep 17 00:00:00 2001 From: Kugan Vivekanandarajah Date: Mon, 30 May 2016 10:45:19 +0000 Subject: [PATCH] re PR tree-optimization/71252 (ICE: verify_ssa failed : definition in block 7 does not dominate use in block 6) gcc/ChangeLog: 2016-05-30 Kugan Vivekanandarajah PR middle-end/71252 * 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-30 Kugan Vivekanandarajah PR middle-end/71252 * gcc.dg/tree-ssa/pr71252-2.c: New test. From-SVN: r236875 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/tree-ssa/pr71252-2.c | 9 +++++++++ gcc/tree-ssa-reassoc.c | 16 ++-------------- 4 files changed, 22 insertions(+), 14 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr71252-2.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 815a43da5ec..c88748f8840 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-05-30 Kugan Vivekanandarajah + + PR middle-end/71252 + * tree-ssa-reassoc.c (swap_ops_for_binary_stmt): Fix swap such that + all fields including stmt_to_insert are swapped. + 2016-05-30 Jan Hubicka * predict.h (force_edge_cold): Declare. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8b989b4e5d6..37f06b78c99 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-05-30 Kugan Vivekanandarajah + + PR middle-end/71252 + * gcc.dg/tree-ssa/pr71252-2.c: New test. + 2016-05-30 Jan Hubicka * gcc.dg/tree-ssa/cunroll-12.c: New testcase. diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr71252-2.c b/gcc/testsuite/gcc.dg/tree-ssa/pr71252-2.c new file mode 100644 index 00000000000..e621d3eb469 --- /dev/null +++ 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 c9ed6795679..d13be29ffc7 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -3763,25 +3763,13 @@ swap_ops_for_binary_stmt (vec 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 -- 2.30.2