This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Non-call exceptions versus cse
- From: Andrew Haley <aph at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 19 Nov 2002 16:21:29 GMT
- Subject: Non-call exceptions versus cse
Consider this code fragment:
int nn = 0;
try
{
int tmp = foo->bar;
nn = tmp;
}
...
When using non-call exceptions, this may not be changed to
int nn = 0;
try
{
nn = foo->bar;
}
...
because the load from foo->bar may trap, in which case nn will not be
set. We don't want data flow analysis incorrectly to conclude that
the original value of nn is dead after this fragment.
As far as I can see it's never correct to CSE two instructions if the
first one may trap.
Andrew.
2002-11-19 Andrew Haley <aph@redhat.com>
* cse.c (cse_insn): Don't cse two insns if the first set may trap.
Index: cse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cse.c,v
retrieving revision 1.242
diff -u -r1.242 cse.c
--- cse.c 12 Oct 2002 00:00:39 -0000 1.242
+++ cse.c 19 Nov 2002 16:14:04 -0000
@@ -6333,7 +6333,8 @@
if (prev != 0 && GET_CODE (prev) == INSN
&& GET_CODE (PATTERN (prev)) == SET
&& SET_DEST (PATTERN (prev)) == SET_SRC (sets[0].rtl)
- && ! find_reg_note (prev, REG_EQUIV, NULL_RTX))
+ && ! find_reg_note (prev, REG_EQUIV, NULL_RTX)
+ && ! (flag_non_call_exceptions && may_trap_p (PATTERN (prev))))
{
rtx dest = SET_DEST (sets[0].rtl);
rtx src = SET_SRC (sets[0].rtl);