From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 115373 invoked by alias); 8 Jul 2015 19:55:09 -0000 Mailing-List: contact jit-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Subscribe: Sender: jit-owner@gcc.gnu.org Received: (qmail 115326 invoked by uid 89); 8 Jul 2015 19:55:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.98.7 on sourceware.org X-Virus-Found: No X-HELO: mail-yk0-f173.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=2cLP1NAXQiaVnC3tGg8L/ozPKT6AiJqglC7Pq8uxhqo=; b=G74mqwVuC4hjeeYOoYxQcpj6/07TctSuCUrR2OBUjn8ujwn+rKvIzK0WA7/0y6mniv CwIMUPk8r7ieiNe/m7joSAFx3IGn9XmR5/6nbuSDA7eK/0bg3s1r6C8So+rAmpAhRrZw toqJq7mHf/68/DFVIJEuzQEG1Zn5JoZg7faMgQpO7/TmdBtyjKXMU7JNegj274jZGDsQ qMPS523mcfDhmWTec3UX/+Z7L54A1USK9F4blYYJcSqKcGKrJAxJDmzyXHjgI4F0vFs3 hVcCJqC4GLAmSuqSVNb0xUof/Dz0i1xzv56tKtYHM4N78uw5tQB2Q+zKii2+xGid4V+d 552A== X-Gm-Message-State: ALoCoQmaO7vGOliQ+fd8wcUBHXTIkRrK6PB4nZVyIuwGjK1suz4rxcmgM52uUUfR+xuOCi8rwCGR MIME-Version: 1.0 X-Received: by 10.170.49.197 with SMTP id 188mr12540792ykr.87.1436385303772; Wed, 08 Jul 2015 12:55:03 -0700 (PDT) In-Reply-To: <1436377619.24803.97.camel@surprise> References: <1436365266.24803.65.camel@surprise> <1436367926.24803.71.camel@surprise> <1436369443.24803.75.camel@surprise> <1436377619.24803.97.camel@surprise> Date: Thu, 01 Jan 2015 00:00:00 -0000 Message-ID: Subject: Re: Filed PR jit/66812 for the code generation issue From: Dibyendu Majumdar To: David Malcolm Cc: jit@gcc.gnu.org Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2015-q3/txt/msg00039.txt.bz2 On 8 July 2015 at 18:46, David Malcolm 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