* Fix RTL load motion bug with -fnon-call-exceptions
@ 2014-07-21 5:14 Eric Botcazou
0 siblings, 0 replies; only message in thread
From: Eric Botcazou @ 2014-07-21 5:14 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 852 bytes --]
We have a testcase that is miscompiled at -O3 by our GCC 4.9-based compiler,
although it isn't by the pristine GCC 4.9 compiler. You need a specific
combination of events (aggressive inlining, -fnon-call-exceptions, memory
accesses marked MEM_NOTRAP_P) which causes RTL load motion to wrongly delete a
MEM_NOTRAP_P load because there is another load from the same address but
without MEM_NOTRAP_P, the root cause being that simple_mem will return true
for the former but false for the latter. Setting MEM_NOTRAP_P is a best
effort thing so not setting it should not lead to wrong code.
Tested on x86-64/Linux, applied on the mainline.
2014-07-20 Eric Botcazou <ebotcazou@adacore.com>
* cse.c (exp_equiv_p) <MEM>: For GCSE, return 0 for expressions with
different trapping status if -fnon-call-exceptions is enabled.
--
Eric Botcazou
[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 653 bytes --]
Index: cse.c
===================================================================
--- cse.c (revision 212833)
+++ cse.c (working copy)
@@ -2687,6 +2687,13 @@ exp_equiv_p (const_rtx x, const_rtx y, i
the same attributes share the same mem_attrs data structure. */
if (MEM_ATTRS (x) != MEM_ATTRS (y))
return 0;
+
+ /* If we are handling exceptions, we cannot consider two expressions
+ with different trapping status as equivalent, because simple_mem
+ might accept one and reject the other. */
+ if (cfun->can_throw_non_call_exceptions
+ && (MEM_NOTRAP_P (x) != MEM_NOTRAP_P (y)))
+ return 0;
}
break;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2014-07-20 21:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-21 5:14 Fix RTL load motion bug with -fnon-call-exceptions Eric Botcazou
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).