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]

[patch] PR 33653: don't optimize volatile mem accesses


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


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