[PATCH, pretty-ipa] Allow unions to be IPA-SRAed

Martin Jambor mjambor@suse.cz
Thu Mar 19 12:31:00 GMT 2009


Hi,

On Wed, Mar 18, 2009 at 05:31:02PM +0100, Jan Hubicka wrote:
> > Hi,
> > 
> > as requested by Honza, the patch below allows unions to be IPA-SRAed.
> > I have bootstrapped and tested it on x86_64-linux and will commit it
> > tomorrow unless someone objects.
> 
> >  	  if ((!is_gimple_reg_type (type)
> >  	       && TREE_CODE (type) != RECORD_TYPE
> > +	       && TREE_CODE (type) != UNION_TYPE
> > +	       && TREE_CODE (type) != QUAL_UNION_TYPE
> >  	       && TREE_CODE (type) != ARRAY_TYPE)
> 
> AGREGATE_TYPE_P tests same condition.  Otherwise it is OK.
> (even today :))

Right, after looking at the code a bit more this is what I have just
committed (after rebootstrapping and re-testing).

Thanks,

Martin

2009-03-19  Martin Jambor  <mjambor@suse.cz>

	* ipa-sra.c (sra_aggregate_type_p): Removed.
	(type_internals_preclude_sra_p): Use AGGREGATE_TYPE_P instead of
	sra_aggregate_type_p.
	(find_param_candidates): Allow all aggregates to be candidates for
	IPA-SRA.  Use AGGREGATE_TYPE_P instead of sra_aggregate_type_p.
	(find_var_candidates): Use AGGREGATE_TYPE_P instead of
	sra_aggregate_type_p.

Index: isra/gcc/ipa-sra.c
===================================================================
--- isra.orig/gcc/ipa-sra.c
+++ isra/gcc/ipa-sra.c
@@ -848,17 +848,6 @@ sra_deinitialize (void)
   pointer_map_destroy (base_access_vec);
 }
 
-/* Return true iff TYPE is one of the types we consider aggregate for SRA
-   tranformations.  */
-
-static inline bool
-sra_aggregate_type_p (tree type)
-{
-  return (TREE_CODE (type) == UNION_TYPE || TREE_CODE (type) == RECORD_TYPE
-	  || TREE_CODE (type) == ARRAY_TYPE
-	  || TREE_CODE (type) == QUAL_UNION_TYPE);
-}
-
 /* Return true iff the type contains a field or element type which dpoes not
    allow scalarization.  */
 
@@ -884,7 +873,7 @@ type_internals_preclude_sra_p (tree type
 		|| !host_integerp (DECL_SIZE (fld), 1))
 	      return true;
 
-	    if (sra_aggregate_type_p (ft)
+	    if (AGGREGATE_TYPE_P (ft)
 		&& type_internals_preclude_sra_p (ft))
 	      return true;
 	  }
@@ -894,7 +883,7 @@ type_internals_preclude_sra_p (tree type
     case ARRAY_TYPE:
       et = TREE_TYPE (type);
 
-      if (sra_aggregate_type_p (et))
+      if (AGGREGATE_TYPE_P (et))
 	return type_internals_preclude_sra_p (et);
       else
 	return false;
@@ -923,35 +912,29 @@ find_param_candidates (void)
       tree type;
 
       count++;
-
       if (TREE_THIS_VOLATILE (parm))
 	continue;
 
       type = TREE_TYPE (parm);
-
       if (POINTER_TYPE_P (type))
 	{
 	  type = TREE_TYPE (type);
 
-	  if ((!is_gimple_reg_type (type)
-	       && TREE_CODE (type) != RECORD_TYPE
-	       && TREE_CODE (type) != ARRAY_TYPE)
+	  if ((!is_gimple_reg_type (type) && !AGGREGATE_TYPE_P (type))
 	      || TREE_CODE (type) == FUNCTION_TYPE
 	      || TYPE_VOLATILE (type))
 	    continue;
 	}
-      else if (TREE_CODE (type) != RECORD_TYPE
-	       && TREE_CODE (type) != ARRAY_TYPE)
+      else if (!AGGREGATE_TYPE_P (type))
 	continue;
 
-
       if (!COMPLETE_TYPE_P (type)
 	  || TREE_ADDRESSABLE (type)
 	  || !host_integerp (TYPE_SIZE (type), 1)
           || tree_low_cst (TYPE_SIZE (type), 1) == 0)
 	continue;
 
-      if (sra_aggregate_type_p (type)
+      if (AGGREGATE_TYPE_P (type)
 	  && type_internals_preclude_sra_p (type))
 	continue;
 
@@ -2743,7 +2726,7 @@ find_var_candidates (void)
         continue;
       type = TREE_TYPE (var);
 
-      if (!sra_aggregate_type_p (type)
+      if (!AGGREGATE_TYPE_P (type)
 	  || needs_to_live_in_memory (var)
 	  || TREE_THIS_VOLATILE (var)
 	  || !COMPLETE_TYPE_P (type)



More information about the Gcc-patches mailing list