public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR48098
@ 2011-03-14 11:33 Richard Guenther
  0 siblings, 0 replies; only message in thread
From: Richard Guenther @ 2011-03-14 11:33 UTC (permalink / raw)
  To: gcc-patches


I am currently testing the following patch for PR48098 which exposes
the fact that TREE_TYPE (vector-type) does not return T when
vector-type is built using make_vector_type (T).  This is because
we move all qualifiers from T to the vector-type and keep an unqualified
element type.  This finally confuses us with the requirement to
preserve conversions to restrict qualified pointers.

I need to think about this more.  For now make the check symmetric
(it's a bug that it wasn't) and compare unqualified types.  Any
issues this hides are missed optimizations with respect to restrict
handling.  It also eventually just postpones verification ICEs to
later phases.

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

Richard.

2011-03-14  Richard Guenther  <rguenther@suse.de>

	PR middle-end/48098
	* tree.c (build_vector_from_val): Adjust assert to requirements
	and reality.

	* gcc.dg/torture/pr48098.c: New testcase.

Index: gcc/tree.c
===================================================================
*** gcc/tree.c	(revision 170933)
--- gcc/tree.c	(working copy)
*************** build_vector_from_val (tree vectype, tre
*** 1376,1383 ****
    if (sc == error_mark_node)
      return sc;
  
!   gcc_assert (useless_type_conversion_p (TREE_TYPE (sc),
! 					 TREE_TYPE (vectype)));
  
    v = VEC_alloc (constructor_elt, gc, nunits);
    for (i = 0; i < nunits; ++i)
--- 1376,1389 ----
    if (sc == error_mark_node)
      return sc;
  
!   /* Verify that the vector type is suitable for SC.  Note that there
!      is some inconsistency in the type-system with respect to restrict
!      qualifications of pointers.  Vector types always have a main-variant
!      element type and the qualification is applied to the vector-type.
!      So TREE_TYPE (vector-type) does not return a properly qualified
!      vector element-type.  */
!   gcc_checking_assert (types_compatible_p (TYPE_MAIN_VARIANT (TREE_TYPE (sc)),
! 					   TREE_TYPE (vectype)));
  
    v = VEC_alloc (constructor_elt, gc, nunits);
    for (i = 0; i < nunits; ++i)
Index: gcc/testsuite/gcc.dg/torture/pr48098.c
===================================================================
*** gcc/testsuite/gcc.dg/torture/pr48098.c	(revision 0)
--- gcc/testsuite/gcc.dg/torture/pr48098.c	(revision 0)
***************
*** 0 ****
--- 1,12 ----
+ /* { dg-do compile } */
+ 
+ void
+ foo (int n)
+ {
+   static char *__restrict *p;
+   int i;
+   p = __builtin_malloc (n);
+   for (i = 0; i < n; i++)
+     p[i] = 0;
+ }
+ 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-03-14 11:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-14 11:33 [PATCH] Fix PR48098 Richard Guenther

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).