+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
(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)
{
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;
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;