This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix PR tree-opt/25500 SRA vs struct containing a vector



if (TREE_CODE (elt->type == RECORD_TYPE)
 for (field = TYPE_FIELDS (elt->type); field; field = TREE_CHAIN (field))
   if (TREE_CODE (field) == FIELD_DECL
       && AGGREGATE_TYPE_P (TREE_TYPE (field)))
     {
       if (num_aggregate++ > 1)
         {
           use_block_copy = false;
           break;
         }
      }

I would even suggest moving it to its own function:


bool single_field_in_record_p (tree type)
{
  int num_fields, num_aggregates;
  if (TREE_CODE (type) != RECORD_TYPE)
    return false;

  for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
    if (TREE_CODE (field) == FIELD_DECL)
      {
        num_fields++;
        if (AGGREGATE_TYPE_P (TREE_TYPE (field))
            && !single_field_in_record_p (TREE_TYPE (field)))
          num_aggregates++;
        if (num_fields == 2)
          break;
      }

  return (num_fields <= 1 && num_aggregates == 0);
}

...

  /* For a single scalar element, use element-by-element copy.
     RTL expansion will figure out how to implement that.  */
  if (single_field_in_record_p (elt->type))
    use_block_copy = false;

Paolo


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]