This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PR51752] publication safety violations in loop invariant motion pass
- From: Torvald Riegel <triegel at redhat dot com>
- To: Aldy Hernandez <aldyh at redhat dot com>
- Cc: Richard Guenther <richard dot guenther at gmail dot com>, Richard Henderson <rth at redhat dot com>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 10 Mar 2012 15:14:57 +0100
- Subject: Re: [PR51752] publication safety violations in loop invariant motion pass
- References: <4F46833C.2090808@redhat.com> <4F46AB9D.7050407@redhat.com> <CAFiYyc2norU+9V0fBhdkz7R_mFeS7gzBHOAqDnuH-HMZejXyew@mail.gmail.com> <1330089023.2986.3085.camel@triegel.csb> <CAFiYyc3RHUsUxxEnWswsrGMWtXXkxpxD3OHc_S3z-FfgxN7Ysw@mail.gmail.com> <4F4BADD1.1090407@redhat.com> <4F4D0965.8020108@redhat.com> <4F4D1277.9080206@redhat.com> <4F4D2719.5000209@redhat.com> <4F4D3504.90005@redhat.com> <CAFiYyc3pOAosTe8a8KOWdjH+J6JXQjaXPUr8AJr6C_JDdmHPew@mail.gmail.com> <4F564F7E.3010300@redhat.com> <CAFiYyc15_-4ohTec93epgarQSrbyFv79fy_dzfWxELF_=LfYxw@mail.gmail.com> <4F5A7AB0.6020709@redhat.com>
On Fri, 2012-03-09 at 15:48 -0600, Aldy Hernandez wrote:
> Torvald is this what you were thinking of?
Yes, but with an exit in the else branch or something that can cause x
not being read after the condition. I _suppose_ that your original
example would be an allowed transformation but just because x would be
read anyway independently of flag's value; we can assume data-race
freedom, and thus we must be able to read x in a data-race-free way even
if flag is false, so flag's value actually doesn't matter.
What about modifying the example like below? In this case, if flag2 is
true, flag's value will matter and we can't move the load to x before
it. Will PRE still introduce "tmp = x + 4" in such an example?
Torvald
> + __transaction_atomic {
> + if (flag)
> + y = x + 4;
> + else
> + // stuff
if (flag2)
return;
> + z = x + 4;
> + }
> +
> + PRE can rewrite this into:
> +
> + __transaction_atomic {
> + if (flag) {
> + tmp = x + 4;
> + y = tmp;
> + } else {
> + // stuff
> + tmp = x + 4;
if (flag2)
return;
> + }
> + z = tmp;
> + }
> +
> + A later pass can move the now totally redundant [x + 4]
> + before its publication predicated by "flag":
> +
> + __transaction_atomic {
> + tmp = x + 4;
> + if (flag) {
> + } else {
> + // stuff
if (flag2)
return;
> + }
> + z = tmp;
> + */