From c265dfbf748e9fc3006a0f844294ef2cea145d71 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Tue, 5 Nov 2019 13:29:52 +0000 Subject: [PATCH] re PR target/92280 (gcc.target/i386/pr83008.c FAILs) 2019-11-05 Richard Biener 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 | 8 ++++++++ gcc/match.pd | 22 +++++++++++++--------- gcc/tree-ssa-forwprop.c | 15 +-------------- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b3d97c27bbd..ca42d43f9ec 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2019-11-05 Richard Biener + + 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 * config/s390/s390.c (s390_vector_alignment): Check if the value diff --git a/gcc/match.pd b/gcc/match.pd index 2c82287f216..eabd01fc115 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -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 *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 *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) diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c index fe55ca958b4..386406fbb38 100644 --- a/gcc/tree-ssa-forwprop.c +++ b/gcc/tree-ssa-forwprop.c @@ -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; -- 2.30.2