re PR target/92280 (gcc.target/i386/pr83008.c FAILs)
authorRichard Biener <rguenther@suse.de>
Tue, 5 Nov 2019 13:29:52 +0000 (13:29 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 5 Nov 2019 13:29:52 +0000 (13:29 +0000)
2019-11-05  Richard Biener  <rguenther@suse.de>

PR tree-optimization/92280
* match.pd (BIT_FIELD_REF of CTOR): Unless the original CTOR
had a single use do not create a new CTOR.
* tree-ssa-forwprop.c (simplify_bitfield_ref): Do not re-fold
BIT_FIELD_REF of a CTOR via GENERIC.

From-SVN: r277832

gcc/ChangeLog
gcc/match.pd
gcc/tree-ssa-forwprop.c

index b3d97c2..ca42d43 100644 (file)
@@ -1,3 +1,11 @@
+2019-11-05  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/92280
+       * match.pd (BIT_FIELD_REF of CTOR): Unless the original CTOR
+       had a single use do not create a new CTOR.
+       * tree-ssa-forwprop.c (simplify_bitfield_ref): Do not re-fold
+       BIT_FIELD_REF of a CTOR via GENERIC.
+
 2019-11-05  Andreas Krebbel  <krebbel@linux.ibm.com>
 
        * config/s390/s390.c (s390_vector_alignment): Check if the value
index 2c82287..eabd01f 100644 (file)
@@ -5565,15 +5565,19 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
         (if (elt < CONSTRUCTOR_NELTS (ctor))
          (view_convert { CONSTRUCTOR_ELT (ctor, elt)->value; })
          { build_zero_cst (type); })
-        {
-          vec<constructor_elt, va_gc> *vals;
-          vec_alloc (vals, count);
-          for (unsigned i = 0;
-               i < count && elt + i < CONSTRUCTOR_NELTS (ctor); ++i)
-            CONSTRUCTOR_APPEND_ELT (vals, NULL_TREE,
-                                    CONSTRUCTOR_ELT (ctor, elt + i)->value);
-          build_constructor (type, vals);
-        })))
+        /* We don't want to emit new CTORs unless the old one goes away.
+           ???  Eventually allow this if the CTOR ends up constant or
+           uniform.  */
+        (if (single_use (@0))
+         {
+           vec<constructor_elt, va_gc> *vals;
+           vec_alloc (vals, count);
+           for (unsigned i = 0;
+                i < count && elt + i < CONSTRUCTOR_NELTS (ctor); ++i)
+             CONSTRUCTOR_APPEND_ELT (vals, NULL_TREE,
+                                     CONSTRUCTOR_ELT (ctor, elt + i)->value);
+           build_constructor (type, vals);
+         }))))
       /* The bitfield references a single constructor element.  */
       (if (k.is_constant (&const_k)
           && idx + n <= (idx / const_k + 1) * const_k)
index fe55ca9..386406f 100644 (file)
@@ -1786,7 +1786,7 @@ simplify_bitfield_ref (gimple_stmt_iterator *gsi)
 {
   gimple *stmt = gsi_stmt (*gsi);
   gimple *def_stmt;
-  tree op, op0, op1, op2;
+  tree op, op0, op1;
   tree elem_type;
   unsigned idx, size;
   enum tree_code code;
@@ -1804,20 +1804,7 @@ simplify_bitfield_ref (gimple_stmt_iterator *gsi)
     return false;
 
   op1 = TREE_OPERAND (op, 1);
-  op2 = TREE_OPERAND (op, 2);
   code = gimple_assign_rhs_code (def_stmt);
-
-  if (code == CONSTRUCTOR)
-    {
-      tree tem = fold_ternary (BIT_FIELD_REF, TREE_TYPE (op),
-                              gimple_assign_rhs1 (def_stmt), op1, op2);
-      if (!tem || !valid_gimple_rhs_p (tem))
-       return false;
-      gimple_assign_set_rhs_from_tree (gsi, tem);
-      update_stmt (gsi_stmt (*gsi));
-      return true;
-    }
-
   elem_type = TREE_TYPE (TREE_TYPE (op0));
   if (TREE_TYPE (op) != elem_type)
     return false;