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

Paolo Bonzini paolo.bonzini@lu.unisi.ch
Wed Nov 15 14:01:00 GMT 2006


> 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



More information about the Gcc-patches mailing list