public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* A new linux/alpha failure
@ 1997-08-30  5:43 H.J. Lu
  1997-09-02 19:51 ` A new linux/alpha failure (aliasing bug) Jim Wilson
  0 siblings, 1 reply; 6+ messages in thread
From: H.J. Lu @ 1997-08-30  5:43 UTC (permalink / raw)
  To: egcs

Hi,

This test is miscompiled on linux/alpha by egcs-970828, but doesn't
happen with gcc 2.7.2.1.

# gcc -O execute/920411-1.c
# a.out
Aborted (core dumped)


-- 
H.J. Lu (hjl@gnu.ai.mit.edu)
--execute/920411-1.c---
long f (w)
     char *w;
{
  long k, i, c = 0, x;
  char *p = (char*) &x;
  for (i = 0; i = 0;) a[i] = ' ';
  if (f (a) != ~0UL / (unsigned char) ~0 * ' ')
    abort ();
  exit (0);
}

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: A new linux/alpha failure (aliasing bug)
  1997-08-30  5:43 A new linux/alpha failure H.J. Lu
@ 1997-09-02 19:51 ` Jim Wilson
  1997-09-02 20:01   ` Jeffrey A Law
                     ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Jim Wilson @ 1997-09-02 19:51 UTC (permalink / raw)
  To: H.J. Lu; +Cc: egcs, jfc

This is due to a bad interaction between the new alias analysis code and
the way that the alpha port works.  The testcase is aliasing a char * and
a long *.  The ANSI C standard allows this.  The way that the new (and old)
aliasing code handled this was to assume that a QImode MEM could alias
anything.  Unfortunately, the alpha (pre ev5 or whatever) does not have char
loads/stores.  So instead of emitting a QImode MEM, it emits a DImode MEM
and then does an extract/insert to get a byte load/store.  Since there
is no QImode MEM, we miss the fact that there is aliasing.  The old code
has the same flaw, but it reports false aliasing so often that we apparently
never noticed the problem.

It appears that we need some way to tell that some non-QImode load/stores
are really char * load/stores.

One possibility is to assume that an AND operator in an address implies
a char * access.  On an Alpha, any QImode/HImode reference will use an
address of the form (mem/s:DI (and:DI (reg:DI 76) (const_int -8))).
The a29k port does the same thing for QImode references if byte operations
are disabled.  Offhand, I do not know of any other port that allows AND in
an address or that is missing byte loads.  This change would solve the problem
at the expense of adding some false aliases for HImode references on the
alpha.  This change should not require any md file changes though.

Other possibilities are to require that patterns that perform a char *
access must have a QImode mem in them or add a special REG_NOTE to indicate
that we have a QImode reference.  However, both of these have the risk that
the optimizer may lose the aliasing info, because it is not directly connected
to the MEM itself.  Safe schemes seem to require that we rely on info that
is inside the MEM itself.

Suggestions welcome.

Jim

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: A new linux/alpha failure (aliasing bug)
  1997-09-02 19:51 ` A new linux/alpha failure (aliasing bug) Jim Wilson
@ 1997-09-02 20:01   ` Jeffrey A Law
  1997-09-02 20:07   ` Richard Henderson
  1997-09-03 10:42   ` Jim Wilson
  2 siblings, 0 replies; 6+ messages in thread
From: Jeffrey A Law @ 1997-09-02 20:01 UTC (permalink / raw)
  To: Jim Wilson; +Cc: H.J. Lu, egcs, jfc

  In message < 199709030251.TAA24369@cygnus.com >you write:
  > One possibility is to assume that an AND operator in an address implies
  > a char * access.  On an Alpha, any QImode/HImode reference will use an
  > address of the form (mem/s:DI (and:DI (reg:DI 76) (const_int -8))).
I think this is the way to go.  In fact, I thought the aliasing code already
knew something about addresses with AND being special.  Maybe it needs to
be extended a little.

Jeff

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: A new linux/alpha failure (aliasing bug)
  1997-09-02 19:51 ` A new linux/alpha failure (aliasing bug) Jim Wilson
  1997-09-02 20:01   ` Jeffrey A Law
@ 1997-09-02 20:07   ` Richard Henderson
  1997-09-03 12:30     ` Jim Wilson
  1997-09-03 10:42   ` Jim Wilson
  2 siblings, 1 reply; 6+ messages in thread
From: Richard Henderson @ 1997-09-02 20:07 UTC (permalink / raw)
  To: Jim Wilson; +Cc: hjl, egcs, jfc

> One possibility is to assume that an AND operator in an address implies
> a char * access.

I thought we already did that, though perhaps in the old alias code.

Yes, in fact I remember having this problem last year, or one like it:

Mon Jul  8 18:00:33 1996  Jim Wilson  <wilson@cygnus.com>

        * cse.c (note_mem_written): Varying structure memory access with
        AND address can alias scalars.
        * sched.c (true_dependence, anti_dependence, output_dependence):
        Likewise.


r~

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: A new linux/alpha failure (aliasing bug)
  1997-09-02 19:51 ` A new linux/alpha failure (aliasing bug) Jim Wilson
  1997-09-02 20:01   ` Jeffrey A Law
  1997-09-02 20:07   ` Richard Henderson
@ 1997-09-03 10:42   ` Jim Wilson
  2 siblings, 0 replies; 6+ messages in thread
From: Jim Wilson @ 1997-09-03 10:42 UTC (permalink / raw)
  To: egcs; +Cc: jfc

FYI I found a minor aliasing typo while working on this problem.

Wed Sep  3 10:36:51 1997  Jim Wilson  <wilson@cygnus.com>

	* alias.c (true_dependence): Test x for BLKmode, in addition to mem.

Index: alias.c
===================================================================
RCS file: /cvs/cvsfiles/egcs/gcc/alias.c,v
retrieving revision 1.4
diff -p -r1.4 alias.c
*** alias.c	1997/08/23 04:39:31	1.4
--- alias.c	1997/09/03 17:36:24
*************** true_dependence (mem, mem_mode, x, varie
*** 815,821 ****
       about aliasing.  */
    if (MEM_IN_STRUCT_P (x) == MEM_IN_STRUCT_P (mem)
        || mem_mode == QImode || mem_mode == BLKmode
!       || GET_MODE (x) == QImode || GET_MODE (mem) == BLKmode
        || varies (x_addr) == varies (mem_addr))
      return 1;
  
--- 815,821 ----
       about aliasing.  */
    if (MEM_IN_STRUCT_P (x) == MEM_IN_STRUCT_P (mem)
        || mem_mode == QImode || mem_mode == BLKmode
!       || GET_MODE (x) == QImode || GET_MODE (x) == BLKmode
        || varies (x_addr) == varies (mem_addr))
      return 1;
  

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: A new linux/alpha failure (aliasing bug)
  1997-09-02 20:07   ` Richard Henderson
@ 1997-09-03 12:30     ` Jim Wilson
  0 siblings, 0 replies; 6+ messages in thread
From: Jim Wilson @ 1997-09-03 12:30 UTC (permalink / raw)
  To: Richard Henderson; +Cc: hjl, egcs, jfc

	I thought we already did that, though perhaps in the old alias code.
	Yes, in fact I remember having this problem last year, or one like it:

	Mon Jul  8 18:00:33 1996  Jim Wilson  <wilson@cygnus.com>

I thought the problem looked familiar.  I guess I forgot to look at the old
alias analysis code before sending mail to egcs.

I suspect that jfc wrote his code before I patched sched.c, which is why
this patch is missing from his code.  I extracted the missing patch and added
it in to the new aliasing code.

Wed Sep  3 12:26:33 1997  Jim Wilson  <wilson@cygnus.com>

	* alias.c (true_dependence): Address with AND can alias scalars.
	(anti_dependence, output_dependence): Likewise.
	
Index: alias.c
===================================================================
RCS file: /cvs/cvsfiles/egcs/gcc/alias.c,v
retrieving revision 1.5
diff -p -r1.5 alias.c
*** alias.c	1997/09/03 17:42:21	1.5
--- alias.c	1997/09/03 19:13:10
*************** memrefs_conflict_p (xsize, x, ysize, y, 
*** 751,761 ****
     changed.  A volatile and non-volatile reference can be interchanged
     though. 
  
!    A MEM_IN_STRUCT reference at a non-QImode 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.  */
  
  /* Read dependence: X is read after read in MEM takes place.  There can
     only be a dependence here if both reads are volatile.  */
--- 751,764 ----
     changed.  A volatile and non-volatile reference can be interchanged
     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
     only be a dependence here if both reads are volatile.  */
*************** true_dependence (mem, mem_mode, x, varie
*** 816,821 ****
--- 819,825 ----
    if (MEM_IN_STRUCT_P (x) == MEM_IN_STRUCT_P (mem)
        || mem_mode == QImode || mem_mode == BLKmode
        || GET_MODE (x) == QImode || GET_MODE (x) == BLKmode
+       || GET_CODE (x_addr) == AND || GET_CODE (mem_addr) == AND
        || varies (x_addr) == varies (mem_addr))
      return 1;
  
*************** anti_dependence (mem, x)
*** 856,864 ****
--- 860,870 ----
  			      SIZE_FOR_MODE (x), XEXP (x, 0), 0)
  	  && ! (MEM_IN_STRUCT_P (mem) && rtx_addr_varies_p (mem)
  		&& GET_MODE (mem) != QImode
+ 		&& GET_CODE (XEXP (mem, 0)) != AND
  		&& ! MEM_IN_STRUCT_P (x) && ! rtx_addr_varies_p (x))
  	  && ! (MEM_IN_STRUCT_P (x) && rtx_addr_varies_p (x)
  		&& GET_MODE (x) != QImode
+ 		&& GET_CODE (XEXP (x, 0)) != AND
  		&& ! MEM_IN_STRUCT_P (mem) && ! rtx_addr_varies_p (mem)));
  }
  
*************** output_dependence (mem, x)
*** 881,889 ****
--- 887,897 ----
  			      SIZE_FOR_MODE (x), XEXP (x, 0), 0)
  	  && ! (MEM_IN_STRUCT_P (mem) && rtx_addr_varies_p (mem)
  		&& GET_MODE (mem) != QImode
+ 		&& GET_CODE (XEXP (mem, 0)) != AND
  		&& ! MEM_IN_STRUCT_P (x) && ! rtx_addr_varies_p (x))
  	  && ! (MEM_IN_STRUCT_P (x) && rtx_addr_varies_p (x)
  		&& GET_MODE (x) != QImode
+ 		&& GET_CODE (XEXP (x, 0)) != AND
  		&& ! MEM_IN_STRUCT_P (mem) && ! rtx_addr_varies_p (mem)));
  }
  



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1997-09-03 12:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-08-30  5:43 A new linux/alpha failure H.J. Lu
1997-09-02 19:51 ` A new linux/alpha failure (aliasing bug) Jim Wilson
1997-09-02 20:01   ` Jeffrey A Law
1997-09-02 20:07   ` Richard Henderson
1997-09-03 12:30     ` Jim Wilson
1997-09-03 10:42   ` Jim Wilson

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).