]> gcc.gnu.org Git - gcc.git/commitdiff
tree-optimization/96579 - another special-operands fix in reassoc
authorRichard Biener <rguenther@suse.de>
Thu, 27 Aug 2020 08:02:22 +0000 (10:02 +0200)
committerRichard Biener <rguenther@suse.de>
Wed, 2 Dec 2020 11:48:18 +0000 (12:48 +0100)
This makes sure to put special-ops expanded rhs left where
expression rewrite expects it.

2020-08-27  Richard Biener  <rguenther@suse.de>

PR tree-optimization/96579
* tree-ssa-reassoc.c (linearize_expr_tree): If we expand
rhs via special ops make sure to swap operands.

* gcc.dg/pr96579.c: New testcase.

(cherry picked from commit ff7463172e564c5dd2432d7af8eaa0124cbd4af7)

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

diff --git a/gcc/testsuite/gcc.dg/pr96579.c b/gcc/testsuite/gcc.dg/pr96579.c
new file mode 100644 (file)
index 0000000..982f8ac
--- /dev/null
@@ -0,0 +1,4 @@
+/* { dg-do compile { target dfp } } */
+/* { dg-options "-O -fno-tree-forwprop -ffast-math -fno-tree-vrp" } */
+
+#include "pr96370.c"
index 9052c7872a55615092f1578e576a26baa4009934..4bc691d5797fed9023d544141466cb540dee2bc1 100644 (file)
@@ -5162,13 +5162,20 @@ linearize_expr_tree (vec<operand_entry *> *ops, gimple *stmt,
 
       if (!binrhsisreassoc)
        {
-         if (!try_special_add_to_ops (ops, rhscode, binrhs, binrhsdef))
+         bool swap = false;
+         if (try_special_add_to_ops (ops, rhscode, binrhs, binrhsdef))
+           /* If we add ops for the rhs we expect to be able to recurse
+              to it via the lhs during expression rewrite so swap
+              operands.  */
+           swap = true;
+         else
            add_to_ops_vec (ops, binrhs);
 
          if (!try_special_add_to_ops (ops, rhscode, binlhs, binlhsdef))
            add_to_ops_vec (ops, binlhs);
 
-         return;
+         if (!swap)
+           return;
        }
 
       if (dump_file && (dump_flags & TDF_DETAILS))
@@ -5187,6 +5194,8 @@ linearize_expr_tree (vec<operand_entry *> *ops, gimple *stmt,
          fprintf (dump_file, " is now ");
          print_gimple_stmt (dump_file, stmt, 0);
        }
+      if (!binrhsisreassoc)
+       return;
 
       /* We want to make it so the lhs is always the reassociative op,
         so swap.  */
This page took 0.067671 seconds and 5 git commands to generate.