From: Dibyendu Majumdar <mobile@majumdar.org.uk>
To: David Malcolm <dmalcolm@redhat.com>
Cc: jit@gcc.gnu.org
Subject: Re: Filed PR jit/66812 for the code generation issue
Date: Thu, 01 Jan 2015 00:00:00 -0000 [thread overview]
Message-ID: <CACXZuxc-AmXDbAmu=ZDQrxf_rOtXUS-gB1_p_vTRB_kPEH9WmA@mail.gmail.com> (raw)
In-Reply-To: <1436377619.24803.97.camel@surprise>
On 8 July 2015 at 18:46, David Malcolm <dmalcolm@redhat.com> wrote:
> I used gcc_jit_function_dump_to_dot to dump the CFG in GraphViz format;
> you can see the result here:
> https://dmalcolm.fedorapeople.org/gcc/2015-07-08/rdump.png
> and with the printfs here:
> https://dmalcolm.fedorapeople.org/gcc/2015-07-08/rdump_ok.png
>
> I see that both paths out of the "entry" block go through empty blocks
> and then into "jmp_5_1".
>
> A similar thing happens later with "jmp_9_2": both paths from the
> conditional lead through empty blocks to "jmp_12_3".
>
> Those pairs of empty blocks look odd. Is the code correct?
>
> Looking at the body of "jmp_5_1", and annotating, I see:
>
> jmp_5_1:
> (&L->ci->u.l.base[(int)1])->value_.b = (int)0;
> (&L->ci->u.l.base[(int)1])->tt_ = (int)1;
>
> comparison_0_11 = (&L->ci->u.l.base[(int)1])->tt_ == (int)0;
> /* this must be true because of the 2nd assignment above */
>
> comparison_0_12 = (&L->ci->u.l.base[(int)1])->tt_ == (int)1;
> /* similarly this must be false */
>
> comparison_0_13 = (&L->ci->u.l.base[(int)1])->value_.b == (int)0;
> /* this must be true because of the 1st assignment above */
>
> isfalse_0_10 = comparison_0_11 || comparison_0_12 && comparison_0_13;
> /* hence we have: true || false && true
> and hence: true */
>
> if (!(!(isfalse_0_10))) goto OP_TEST_do_jmp_5_14; else goto OP_TEST_do_skip_5_15;
> /* hence this always takes the 1st path;
> the 2nd path is indeed dead code */
>
> So it does in fact seem reasonable for the optimizer to optimize away
> OP_TEST_do_skip_5_15, and I think that once it does that, it merges
> OP_TEST_do_jmp_5_14 and jmp_9_2 into jmp_5_1, and can then do similar
> optimizations to the statements that were in jmp_9_2.
>
> So it seems that things I reported pass "fre1" as doing are reasonable.
>
> It seems that the optimizer is only able to assume the above values when
> strict aliasing is enabled, but it seems to be a reasonable
> optimization. (I suspect that for some reason the presence of the
> printfs also is stopping this optimization; perhaps JIT doesn't know as
> much as the C frontend about the lack of side-effects of printf?)
>
> Is the code being supplied correct? It's not clear to me what it's
> meant to be doing, but that CFG looks curious to me. Maybe the input is
> incorrect, but it only turns into a problem when optimized?
I did check the generated code before for correctness but will do so
again, just to be sure. If the generated code was incorrect though the
test would fail under -O1 as well I would have thought.
Regards
Dibyendu
next prev parent reply other threads:[~2015-07-08 19:55 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-01 0:00 A possible " Dibyendu Majumdar
2015-01-01 0:00 ` Dibyendu Majumdar
2015-01-01 0:00 ` Dibyendu Majumdar
2015-01-01 0:00 ` Dibyendu Majumdar
2015-01-01 0:00 ` David Malcolm
2015-01-01 0:00 ` Dibyendu Majumdar
2015-01-01 0:00 ` Dibyendu Majumdar
2015-01-01 0:00 ` Dibyendu Majumdar
2015-01-01 0:00 ` PR jit/66783 (Re: A possible code generation issue) David Malcolm
2015-01-01 0:00 ` [PATCH, committed] PR jit/66783: prevent use of opaque structs David Malcolm
2015-01-01 0:00 ` Filed PR jit/66811: jit jumps aren't compilable as C (Re: A possible code generation issue) David Malcolm
2015-01-01 0:00 ` Filed PR jit/66811: jit dumps " David Malcolm
2015-01-01 0:00 ` Filed PR jit/66812 for the code generation issue David Malcolm
2015-01-01 0:00 ` David Malcolm
2015-01-01 0:00 ` David Malcolm
2015-01-01 0:00 ` David Malcolm
2015-01-01 0:00 ` Dibyendu Majumdar
2015-01-01 0:00 ` David Malcolm
2015-01-01 0:00 ` Dibyendu Majumdar
2015-01-01 0:00 ` David Malcolm
2015-01-01 0:00 ` Dibyendu Majumdar
2015-01-01 0:00 ` Dibyendu Majumdar
2015-01-01 0:00 ` David Malcolm
2015-01-01 0:00 ` Dibyendu Majumdar
2015-01-01 0:00 ` David Malcolm
2015-01-01 0:00 ` David Malcolm
2015-01-01 0:00 ` [PATCH] PR jit/66812: Candidate fix for for the code generation issue, v1 David Malcolm
2015-01-01 0:00 ` Dibyendu Majumdar
2015-01-01 0:00 ` David Malcolm
2015-01-01 0:00 ` Dibyendu Majumdar
2015-01-01 0:00 ` Dibyendu Majumdar
2015-01-01 0:00 ` David Malcolm
2015-01-01 0:00 ` Dibyendu Majumdar
2015-01-01 0:00 ` Dibyendu Majumdar
2015-01-01 0:00 ` Filed PR jit/66812 for the code generation issue Dibyendu Majumdar
2015-01-01 0:00 ` Dibyendu Majumdar [this message]
2015-01-01 0:00 ` Dibyendu Majumdar
2015-01-01 0:00 ` Dibyendu Majumdar
2015-01-01 0:00 ` Dibyendu Majumdar
2015-01-01 0:00 ` Dibyendu Majumdar
2015-01-01 0:00 ` Dibyendu Majumdar
2015-01-01 0:00 ` David Malcolm
2015-01-01 0:00 ` David Malcolm
2015-01-01 0:00 ` Dibyendu Majumdar
2015-01-01 0:00 ` Dibyendu Majumdar
2015-01-01 0:00 ` David Malcolm
2015-01-01 0:00 ` Dibyendu Majumdar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CACXZuxc-AmXDbAmu=ZDQrxf_rOtXUS-gB1_p_vTRB_kPEH9WmA@mail.gmail.com' \
--to=mobile@majumdar.org.uk \
--cc=dmalcolm@redhat.com \
--cc=jit@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).