Alias handling of QImode

Richard Kenner kenner@vlsi1.ultra.nyu.edu
Sat May 20 06:29:00 GMT 2000


I moved the code for it from alias.c to c-common.c since other languages
don't have this restriction.  Tested on alpha.

Sat May 20 09:30:55 2000  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>

	* alias.c (aliases_everything_p): Don't special-case QImode here.
	* c-common.c (c_get_alias_set): Do it here.
	Handle BIT_FIELD_REF by getting alias info for arg.
	Use POINTER_TYPE_P.

*** alias.c	2000/05/19 22:27:26	1.79
--- alias.c	2000/05/20 13:16:21
*************** memrefs_conflict_p (xsize, x, ysize, y, 
*** 1214,1225 ****
     though. 
  
!    A MEM_IN_STRUCT reference at a non-QImode non-AND varying address can never
!    conflict with a non-MEM_IN_STRUCT reference at a fixed address.   We must
!    allow QImode aliasing because the ANSI C standard allows character
!    pointers to alias anything.  We are assuming that characters are
!    always QImode here.  We also must allow AND addresses, because they may
!    generate accesses outside the object being referenced.  This is used to
!    generate aligned addresses from unaligned addresses, for instance, the
!    alpha storeqi_unaligned pattern.  */
  
  /* Read dependence: X is read after read in MEM takes place.  There can
--- 1214,1223 ----
     though. 
  
!    A MEM_IN_STRUCT reference at a non-AND varying address can never
!    conflict with a non-MEM_IN_STRUCT reference at a fixed address.  We
!    also must allow AND addresses, because they may generate accesses
!    outside the object being referenced.  This is used to generate
!    aligned addresses from unaligned addresses, for instance, the alpha
!    storeqi_unaligned pattern.  */
  
  /* Read dependence: X is read after read in MEM takes place.  There can
*************** aliases_everything_p (mem)
*** 1270,1277 ****
       rtx mem;
  {
-   if (GET_MODE (mem) == QImode)
-     /* ANSI C says that a `char*' can point to anything.  */
-     return 1;
- 
    if (GET_CODE (XEXP (mem, 0)) == AND)
      /* If the address is an AND, its very hard to know at what it is
--- 1268,1271 ----
*** c-common.c	2000/05/05 18:16:49	1.109
--- c-common.c	2000/05/20 13:16:26
*************** c_get_alias_set (t)
*** 3333,3338 ****
      return 0;
  
!   type = (TYPE_P (t)) ? t : TREE_TYPE (t);
  
    if (type == error_mark_node)
      return 0;
--- 3333,3344 ----
      return 0;
  
!   /* For a bit field reference that's not to a specific field,
!      all we can say is the aliasing information for the underlying object. */
!   if (TREE_CODE (t) == BIT_FIELD_REF)
!     t = TREE_OPERAND (t, 0);
  
+   /* If this is a type, use it, otherwise get the type of the expression.
+      If the type is an error type, say this may alias anything.  */
+   type = TYPE_P (t) ? t : TREE_TYPE (t);
    if (type == error_mark_node)
      return 0;
*************** c_get_alias_set (t)
*** 3341,3351 ****
       we're interested in more than just the type.  */
  
-   if (TREE_CODE (t) == BIT_FIELD_REF)
-     /* Perhaps reads and writes to this piece of data alias fields
-        neighboring the bitfield.  Perhaps that's impossible.  For now,
-        let's just assume that bitfields can alias everything, which is
-        the conservative assumption.  */
-     return 0;
- 
    /* Permit type-punning when accessing a union, provided the access
       is directly through the union.  For example, this code does not
--- 3347,3350 ----
*************** c_get_alias_set (t)
*** 3364,3372 ****
      {
        /* Check for accesses through restrict-qualified pointers.  */
!       tree decl = c_find_base_decl (TREE_OPERAND (t, 0));
  
        if (decl && DECL_POINTER_ALIAS_SET_KNOWN_P (decl))
  	/* We use the alias set indicated in the declaration.  */
  	return DECL_POINTER_ALIAS_SET (decl);
      }
  
--- 3363,3379 ----
      {
        /* Check for accesses through restrict-qualified pointers.  */
!       tree op = TREE_OPERAND (t, 0);
!       tree decl = c_find_base_decl (op);
  
        if (decl && DECL_POINTER_ALIAS_SET_KNOWN_P (decl))
  	/* We use the alias set indicated in the declaration.  */
  	return DECL_POINTER_ALIAS_SET (decl);
+ 
+       /* If this is a char *, the ANSI C standard says it can alias
+          anything.  */
+       if (TREE_CODE (TREE_TYPE (op)) == INTEGER_TYPE
+ 	  && (TYPE_PRECISION (TREE_TYPE (op))
+ 	      == TYPE_PRECISION (char_type_node)))
+ 	return 0;
      }
  
*************** c_get_alias_set (t)
*** 3425,3430 ****
         we don't yet make any use of that information.)  */
      TYPE_ALIAS_SET (type) = 0;
!   else if (TREE_CODE (type) == POINTER_TYPE
! 	   || TREE_CODE (type) == REFERENCE_TYPE)
      {
        tree t;
--- 3432,3436 ----
         we don't yet make any use of that information.)  */
      TYPE_ALIAS_SET (type) = 0;
!   else if (POINTER_TYPE_P (type))
      {
        tree t;
*************** c_get_alias_set (t)
*** 3460,3464 ****
      }
  
!   if (!TYPE_ALIAS_SET_KNOWN_P (type))
      /* TYPE is something we haven't seen before.  Put it in a new
         alias set.  */
--- 3466,3470 ----
      }
  
!   if (! TYPE_ALIAS_SET_KNOWN_P (type))
      /* TYPE is something we haven't seen before.  Put it in a new
         alias set.  */


More information about the Gcc-patches mailing list