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]
Other format: [Raw text]

PR opt/12826


Hi,
loop misses the volatile flag because it is just on some memory references.
While this is somewhat dubious testcase, it is not very dificult to fix loop to
deal with it.
/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
/* { dg-options "-O2" } */
/* { dg-final { scan-assembler "testb" } } */
ftn (char *sp)
{
  char status;

  while (1)
    {
      *sp = 0xE8;
      status = *(volatile char *) sp;
      if (status & 0x80)
	break;
    }
}

Bootstrapping/regtesting in process, OK?

2004-01-10  Jan Hubicka  <jh@suse.cz>
	PR opt/12826
	* loop.c (insert_loop_mem): Preffer VOLATILE memory references to be
	stored.
Index: loop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop.c,v
retrieving revision 1.485
diff -c -3 -p -r1.485 loop.c
*** loop.c	6 Jan 2004 16:51:17 -0000	1.485
--- loop.c	10 Jan 2004 22:51:09 -0000
*************** insert_loop_mem (rtx *mem, void *data AT
*** 9561,9566 ****
--- 9561,9568 ----
    for (i = 0; i < loop_info->mems_idx; ++i)
      if (rtx_equal_p (m, loop_info->mems[i].mem))
        {
+ 	if (MEM_VOLATILE_P (m) && !MEM_VOLATILE_P (loop_info->mems[i].mem))
+ 	  loop_info->mems[i].mem = m;
  	if (GET_MODE (m) != GET_MODE (loop_info->mems[i].mem))
  	  /* The modes of the two memory accesses are different.  If
  	     this happens, something tricky is going on, and we just


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