[PATCH][mem-ref2] Fixup restrict conversions

Richard Guenther rguenther@suse.de
Wed Mar 31 11:25:00 GMT 2010


The ordering between restrict cast preservation and void cast
disregarding became important now.  Otherwise we violate
transitivity.

Bootstrap & regtest ongoing on x86_64-unknown-linux-gnu, will apply
to the branch once that succeeded.

Richard.

2010-03-31  Richard Guenther  <rguenther@suse.de>

	* tree-ssa.c (useless_type_conversion_p): Move restrict
	cast conversion check before void type check.

Index: tree-ssa.c
===================================================================
--- tree-ssa.c	(revision 157630)
+++ tree-ssa.c	(working copy)
@@ -1209,6 +1209,12 @@ useless_type_conversion_p (tree outer_ty
 	  != TYPE_ADDR_SPACE (TREE_TYPE (inner_type)))
 	return false;
 
+      /* Do not lose casts to restrict qualified pointers.  */
+      if ((TYPE_RESTRICT (outer_type)
+	   != TYPE_RESTRICT (inner_type))
+	  && TYPE_RESTRICT (outer_type))
+	return false;
+
       /* If the outer type is (void *) or a pointer to an incomplete
 	 record type or a pointer to an unprototyped function,
 	 then the conversion is not necessary.  */
@@ -1221,12 +1227,6 @@ useless_type_conversion_p (tree outer_ty
 	      && useless_type_conversion_p (TREE_TYPE (TREE_TYPE (outer_type)),
 					    TREE_TYPE (TREE_TYPE (inner_type)))))
 	return true;
-
-      /* Do not lose casts to restrict qualified pointers.  */
-      if ((TYPE_RESTRICT (outer_type)
-	   != TYPE_RESTRICT (inner_type))
-	  && TYPE_RESTRICT (outer_type))
-	return false;
     }
 
   /* From now on qualifiers on value types do not matter.  */



More information about the Gcc-patches mailing list