public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch] PR 33653: don't optimize volatile mem accesses
@ 2007-10-04 10:13 Michael Matz
  2007-10-04 10:27 ` Eric Botcazou
  2007-10-04 11:16 ` Paolo Bonzini
  0 siblings, 2 replies; 7+ messages in thread
From: Michael Matz @ 2007-10-04 10:13 UTC (permalink / raw)
  To: gcc-patches

Hi,

dce.c and dse.c use the wrong predicates to check if an insn is 
undeletable because of volatile accesses.  They use volatile_insn_p(), 
whereas they should use volatile_refs_p() (like the old flow code did).

I've started testing.  Okay for trunk?  How can I best check for the 
existence of the memory access in the testsuite?

The testcase looks like so:

void f (volatile char *p)
{
  char c = p[0];
}

Is it possible in our testsuite to check that RTL doesn't optimize away 
the volatile read?


Ciao,
Michael.
--
	* dce.c (deletable_insn_p_1): Use volatile_refs_p().
	* dse.c (scan_insn): Same.

Index: dce.c
===================================================================
--- dce.c	(revision 129000)
+++ dce.c	(working copy)
@@ -78,7 +78,7 @@ deletable_insn_p_1 (rtx body)
       return false;
 
     default:
-      if (volatile_insn_p (body))
+      if (volatile_refs_p (body))
 	return false;
 
       if (flag_non_call_exceptions && may_trap_p (body))
Index: dse.c
===================================================================
--- dse.c	(revision 129000)
+++ dse.c	(working copy)
@@ -1997,7 +1997,7 @@ scan_insn (bb_info_t bb_info, rtx insn)
   /* Assuming that there are sets in these insns, we cannot delete
      them.  */
   if ((GET_CODE (PATTERN (insn)) == CLOBBER)
-      || volatile_insn_p (PATTERN (insn))
+      || volatile_refs_p (PATTERN (insn))
       || (flag_non_call_exceptions && may_trap_p (PATTERN (insn)))
       || (RTX_FRAME_RELATED_P (insn))
       || find_reg_note (insn, REG_FRAME_RELATED_EXPR, NULL_RTX))

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

* Re: [patch] PR 33653: don't optimize volatile mem accesses
  2007-10-04 10:13 [patch] PR 33653: don't optimize volatile mem accesses Michael Matz
@ 2007-10-04 10:27 ` Eric Botcazou
  2007-10-04 11:16 ` Paolo Bonzini
  1 sibling, 0 replies; 7+ messages in thread
From: Eric Botcazou @ 2007-10-04 10:27 UTC (permalink / raw)
  To: Michael Matz; +Cc: gcc-patches

> dce.c and dse.c use the wrong predicates to check if an insn is
> undeletable because of volatile accesses.  They use volatile_insn_p(),
> whereas they should use volatile_refs_p() (like the old flow code did).
>
> I've started testing.  Okay for trunk?

Obvious I'd think, but nevertheless OK. :-)

> Is it possible in our testsuite to check that RTL doesn't optimize away
> the volatile read?

By testing that we have a non-null frame at -O or above?

-- 
Eric Botcazou

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

* Re: [patch] PR 33653: don't optimize volatile mem accesses
  2007-10-04 10:13 [patch] PR 33653: don't optimize volatile mem accesses Michael Matz
  2007-10-04 10:27 ` Eric Botcazou
@ 2007-10-04 11:16 ` Paolo Bonzini
  2007-10-04 12:14   ` Michael Matz
  1 sibling, 1 reply; 7+ messages in thread
From: Paolo Bonzini @ 2007-10-04 11:16 UTC (permalink / raw)
  To: gcc-patches


> Is it possible in our testsuite to check that RTL doesn't optimize away 
> the volatile read?

You could make it p[5678] and scan RTL dumps for 5678?

Paolo

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

* Re: [patch] PR 33653: don't optimize volatile mem accesses
  2007-10-04 11:16 ` Paolo Bonzini
@ 2007-10-04 12:14   ` Michael Matz
  2007-10-04 12:25     ` Paolo Bonzini
  2007-10-04 13:36     ` Michael Matz
  0 siblings, 2 replies; 7+ messages in thread
From: Michael Matz @ 2007-10-04 12:14 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: gcc-patches

Hi,

On Thu, 4 Oct 2007, Paolo Bonzini wrote:

> > Is it possible in our testsuite to check that RTL doesn't optimize 
> > away the volatile read?
> 
> You could make it p[5678] and scan RTL dumps for 5678?

I like that idea.  But it doesn't seem to work for machines which split 
immediates.  I now think (after trying with signals, which would require 
limiting the number of test platforms) that it's enough to simply check 
for "mem/v" in any late dump.  I chose "shorten" as it seems to be the 
latest one which is run on all platforms.

So, I'll use the below as gcc.dg/pr33653.c.


Ciao,
Michael.

/* { dg-do compile } */
/* { dg-options "-O2 -fdump-rtl-shorten" } */

void f (volatile char *p)
{
  char c = p[0];
}

/* { dg-final { scan-rtl-dump "mem/v" "shorten" } } */
/* { dg-final { cleanup-rtl-dump "shorten" } } */

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

* Re: [patch] PR 33653: don't optimize volatile mem accesses
  2007-10-04 12:14   ` Michael Matz
@ 2007-10-04 12:25     ` Paolo Bonzini
  2007-10-04 12:29       ` Michael Matz
  2007-10-04 13:36     ` Michael Matz
  1 sibling, 1 reply; 7+ messages in thread
From: Paolo Bonzini @ 2007-10-04 12:25 UTC (permalink / raw)
  To: Michael Matz; +Cc: gcc-patches


>>> Is it possible in our testsuite to check that RTL doesn't optimize 
>>> away the volatile read?
>> You could make it p[5678] and scan RTL dumps for 5678?
> 
> I like that idea.  But it doesn't seem to work for machines which split 
> immediates.  I now think (after trying with signals, which would require 
> limiting the number of test platforms) that it's enough to simply check 
> for "mem/v" in any late dump.  I chose "shorten" as it seems to be the 
> latest one which is run on all platforms.

Yeah, that should also work.  I would have thought that the 5678 would 
be still present in some REG_EQUAL note.

Paolo

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

* Re: [patch] PR 33653: don't optimize volatile mem accesses
  2007-10-04 12:25     ` Paolo Bonzini
@ 2007-10-04 12:29       ` Michael Matz
  0 siblings, 0 replies; 7+ messages in thread
From: Michael Matz @ 2007-10-04 12:29 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: gcc-patches

Hi,

On Thu, 4 Oct 2007, Paolo Bonzini wrote:

> 
> > > > Is it possible in our testsuite to check that RTL doesn't optimize away
> > > > the volatile read?
> > > You could make it p[5678] and scan RTL dumps for 5678?
> > 
> > I like that idea.  But it doesn't seem to work for machines which split
> > immediates.  I now think (after trying with signals, which would require
> > limiting the number of test platforms) that it's enough to simply check for
> > "mem/v" in any late dump.  I chose "shorten" as it seems to be the latest
> > one which is run on all platforms.
> 
> Yeah, that should also work.  I would have thought that the 5678 would be
> still present in some REG_EQUAL note.

Yes, that's what I also thought initially, but on ppc 56789 is constructed 
very early (cse1 or fwprop1) as 0x10000 - 8747, without any REG_EQUAL 
notes.


Ciao,
Michael.

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

* Re: [patch] PR 33653: don't optimize volatile mem accesses
  2007-10-04 12:14   ` Michael Matz
  2007-10-04 12:25     ` Paolo Bonzini
@ 2007-10-04 13:36     ` Michael Matz
  1 sibling, 0 replies; 7+ messages in thread
From: Michael Matz @ 2007-10-04 13:36 UTC (permalink / raw)
  To: gcc-patches

Hi,

On Thu, 4 Oct 2007, Michael Matz wrote:

> So, I'll use the below as gcc.dg/pr33653.c.

bootstraped/regtested on x86_64-linux, checked in.


Ciao,
Michael.

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

end of thread, other threads:[~2007-10-04 13:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-04 10:13 [patch] PR 33653: don't optimize volatile mem accesses Michael Matz
2007-10-04 10:27 ` Eric Botcazou
2007-10-04 11:16 ` Paolo Bonzini
2007-10-04 12:14   ` Michael Matz
2007-10-04 12:25     ` Paolo Bonzini
2007-10-04 12:29       ` Michael Matz
2007-10-04 13:36     ` Michael Matz

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