diff options
author | Jeff Law <law@redhat.com> | 2017-09-05 23:20:25 -0600 |
---|---|---|
committer | Jeff Law <law@gcc.gnu.org> | 2017-09-05 23:20:25 -0600 |
commit | 5aa102aa78e6256fabae6beca698d533e27348ff (patch) | |
tree | dea5ae204ecf512a5da8667c9133f66b5b2ce877 | |
parent | 1d441507f7837bbff2c208e731940e6cc460194e (diff) | |
download | gcc-5aa102aa78e6256fabae6beca698d533e27348ff.zip gcc-5aa102aa78e6256fabae6beca698d533e27348ff.tar.gz gcc-5aa102aa78e6256fabae6beca698d533e27348ff.tar.bz2 |
re PR tree-optimization/64910 (tree reassociation results in poor code)
PR tree-optimization/64910
* tree-ssa-reassoc.c (reassociate_bb): Restrict last change to
cases where we have 3 or more operands.
From-SVN: r251751
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/tree-ssa-reassoc.c | 17 |
2 files changed, 15 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5363790..1b3bddb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-09-05 Jeff Law <law@redhat.com> + + PR tree-optimization/64910 + * tree-ssa-reassoc.c (reassociate_bb): Restrict last change to + cases where we have 3 or more operands. + 2017-09-05 Jakub Jelinek <jakub@redhat.com> PR middle-end/81768 diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index 7604819..2fb6aef 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -5763,14 +5763,15 @@ reassociate_bb (basic_block bb) "Width = %d was chosen for reassociation\n", width); - /* For binary bit operations, if the last operand in - OPS is a constant, move it to the front. This - helps ensure that we generate (X & Y) & C rather - than (X & C) & Y. The former will often match - a canonical bit test when we get to RTL. */ - if ((rhs_code == BIT_AND_EXPR - || rhs_code == BIT_IOR_EXPR - || rhs_code == BIT_XOR_EXPR) + /* For binary bit operations, if there are at least 3 + operands and the last last operand in OPS is a constant, + move it to the front. This helps ensure that we generate + (X & Y) & C rather than (X & C) & Y. The former will + often match a canonical bit test when we get to RTL. */ + if (ops.length () != 2 + && (rhs_code == BIT_AND_EXPR + || rhs_code == BIT_IOR_EXPR + || rhs_code == BIT_XOR_EXPR) && TREE_CODE (ops.last ()->op) == INTEGER_CST) std::swap (*ops[0], *ops[ops_num - 1]); |