This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Fix to -O3 aliasing problems


As discussed in the GCC list, there were two problems.  This fixes both.
I applied these to both the branch and mainline and tested on the mainline
on alphaev56 and on the branch with a bootstrap on ia32.

Mon Mar 12 14:05:32 2001  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>

	* flow.c (insn_dead_p): Don't consider two memrefs equivalent
	unless anti_dependence says they are.
	* alias.c (objects_must_conflict): If neither has a type specified,
	they must conflict.

*** flow.c	2001/02/24 02:32:33	1.381
--- flow.c	2001/03/12 19:02:18
*************** insn_dead_p (pbi, x, call_ok, notes)
*** 4421,4445 ****
  	     and see if one is an identical match to this memory location.
  	     If so, this memory write is dead (remember, we're walking
! 	     backwards from the end of the block to the start).  */
! 	  temp = pbi->mem_set_list;
! 	  while (temp)
! 	    {
! 	      rtx mem = XEXP (temp, 0);
  
! 	      if (rtx_equal_p (mem, r))
! 		return 1;
  #ifdef AUTO_INC_DEC
! 	      /* Check if memory reference matches an auto increment. Only
! 		 post increment/decrement or modify are valid.  */
! 	      if (GET_MODE (mem) == GET_MODE (r)
! 	          && (GET_CODE (XEXP (mem, 0)) == POST_DEC
! 	              || GET_CODE (XEXP (mem, 0)) == POST_INC
! 	              || GET_CODE (XEXP (mem, 0)) == POST_MODIFY)
! 		  && GET_MODE (XEXP (mem, 0)) == GET_MODE (r)
! 		  && rtx_equal_p (XEXP (XEXP (mem, 0), 0), XEXP (r, 0)))
! 		return 1;
  #endif
! 	      temp = XEXP (temp, 1);
! 	    }
  	}
        else
--- 4421,4446 ----
  	     and see if one is an identical match to this memory location.
  	     If so, this memory write is dead (remember, we're walking
! 	     backwards from the end of the block to the start).  Since
! 	     rtx_equal_p does not check the alias set or flags, we also
! 	     must have the potential for them to conflict (anti_dependence). */
! 	  for (temp = pbi->mem_set_list; temp != 0; temp = XEXP (temp, 1))
! 	    if (anti_dependence (r, XEXP (temp, 0)))
! 	      {
! 		rtx mem = XEXP (temp, 0);
  
! 		if (rtx_equal_p (mem, r))
! 		  return 1;
  #ifdef AUTO_INC_DEC
! 		/* Check if memory reference matches an auto increment. Only
! 		   post increment/decrement or modify are valid.  */
! 		if (GET_MODE (mem) == GET_MODE (r)
! 		    && (GET_CODE (XEXP (mem, 0)) == POST_DEC
! 			|| GET_CODE (XEXP (mem, 0)) == POST_INC
! 			|| GET_CODE (XEXP (mem, 0)) == POST_MODIFY)
! 		    && GET_MODE (XEXP (mem, 0)) == GET_MODE (r)
! 		    && rtx_equal_p (XEXP (XEXP (mem, 0), 0), XEXP (r, 0)))
! 		  return 1;
  #endif
! 	      }
  	}
        else
*** alias.c	2001/01/26 22:32:51	1.115
--- alias.c	2001/03/12 19:02:22
*************** objects_must_conflict_p (t1, t2)
*** 310,313 ****
--- 310,319 ----
       tree t1, t2;
  {
+   /* If neither has a type specified, we don't know if they'll conflict
+      because we may be using them to store objects of various types, for
+      example the argument and local variables areas of inlined functions.  */
+   if (t1 == 0 && t1 == 0)
+     return 0;
+ 
    /* If one or the other has readonly fields or is readonly,
       then they may not conflict.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]