From: Jeff Law <law@redhat.com>
To: Arnaud Lacombe <lacombar@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
Ian Lance Taylor <iant@google.com>,
gcc-help@gcc.gnu.org, stufever@gmail.com,
linux-kernel@vger.kernel.org,
Wang Shaoyan <wangshaoyan.pt@taobao.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
Ingo Molnar <mingo@redhat.com>
Subject: Re: [PATCH] TRACING: Fix a copmile warning
Date: Tue, 26 Jul 2011 14:43:56 -0600 [thread overview]
Message-ID: <4E2F270C.7020100@redhat.com> (raw)
In-Reply-To: <CACqU3MXysWUYNnNQniR5LB4x1UGhJqwoYnTFmj=U8do-qRghow@mail.gmail.com>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 07/25/11 19:19, Arnaud Lacombe wrote:
> Hi,
>
> On Mon, Jul 25, 2011 at 9:12 PM, Steven Rostedt <rostedt@goodmis.org> wrote:
>> On Mon, 2011-07-25 at 21:08 -0400, Arnaud Lacombe wrote:
>>> Hi,
>>>
>>
>>> but the code generated seem to test %esi (`b', potentially
>>> uninitialized) before %ebx (`a'). Am I still missing something ?
>>
>> But it tests 'a' again afterward. If 'a' is 0, it doesn't matter what
>> 'b' was. So the uninitialized test is a wash. No harm done, except for
>> some wasted CPU cycles.
>>
> I see, even if `b' is junk, the final logic does not change.
Right.
Here's the .optimized dump I get for -Os:
<bb 2>:
a_2 = e ();
if (a_2 != 0B)
goto <bb 3>;
else
goto <bb 4>;
<bb 3>:
b_4 = f ();
<bb 4>:
# b_1 = PHI <b_3(D)(2), b_4(3)>
D.2708_5 = a_2 != 0B;
D.2709_6 = b_1 != 0B;
D.2710_7 = D.2709_6 & D.2708_5;
if (D.2710_7 != 0)
goto <bb 5>;
else
goto <bb 6>;
<bb 5>:
g (); [tail call]
<bb 6>:
return;
If we duplicate bb4 and isolate the paths leading out of bb2 we'd get
something like this:
<bb 2>:
a_2 = e ();
if (a_2 != 0B)
goto <bb 3>;
else
goto <bb 7>;
<bb 3>:
b_4 = f ();
<bb 4>:
# b_1 = PHI b_4(3)>
D.2708_5 = a_2 != 0B;
D.2709_6 = b_1 != 0B;
D.2710_7 = D.2709_6 & D.2708_5;
if (D.2710_7 != 0)
goto <bb 5>;
else
goto <bb 6>;
<bb 5>:
g (); [tail call]
<bb 6>:
return;
<bb 7>:
# b_1 = PHI <b_3(D)(2))>
D.2708_5 = a_2 != 0B;
D.2709_6 = b_1 != 0B;
D.2710_7 = D.2709_6 & D.2708_5;
if (D.2710_7 != 0)
goto <bb 5>;
else
goto <bb 6>;
[I'm not going to fix all the SSA_NAMEs, I'm just showing roughly what
can be done with this code... ]
Then we can propagate the fact that a_2 == 0 into bb7 and a2 != 0 into
bb4. That in turn allows bb7 to collapse into "goto bb6" and bb4
simplifies into if (b4 != 0) goto bb5 else goto bb6. CFG
simplifications then eliminate the jump and combine bb3 & bb4 resulting in:
<bb 2>:
a_2 = e ();
if (a_2 != 0B)
goto <bb 3>;
else
goto <bb 6>;
<bb 3>:
b_4 = f ();
if (b_4 != 0)
goto <bb 5>;
else
goto <bb 6>;
<bb 5>:
g (); [tail call]
<bb 6>:
return;
Which just happens to be the code we get from -O2. Unfortunately we
don't in general know when block duplication of this nature is going to
allow enough simplification to justify the possible code expansion.
Thus block duplication of this nature is severely limited when compiling
with -Os.
Jeff
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iQEcBAEBAgAGBQJOLycMAAoJEBRtltQi2kC7wbQH/RO2vAAEoHFuJKapNewMcL39
Fm404+DxN1BWwt6HT1BQYfH9tpZCepAJzDVcVsYWFlDOabLUKos9Sju/O8qkSkWK
gYdZ/XbhntB+vNaEQEXz+DdDnbX1OCPCTwM5bjtJ6Gwkjk5W7fa+GHFo694UZ0fH
fgKpAuTVFaCGj94whReGmsNDe0CbpBYS9+Erx4uUsasfkyy5sLDwGaM7gEtg0VS/
ZMz2bP1RDslk3WVkitllO9msq7i70dlR8qw8UgaUSyyvpNrw0HcRxXoI9ZB82mm4
QCtrRD5S92gxdzTtJ0Jg6co+tS2NadDv4D4f9Fn1Ox2oE/oYWvKBvLgkI8Up2pk=
=5lTt
-----END PGP SIGNATURE-----
next prev parent reply other threads:[~2011-07-26 20:44 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-18 9:40 [PATCH] TRACING: Fix a copmile warning stufever
2011-07-25 18:32 ` Steven Rostedt
2011-07-25 19:43 ` Arnaud Lacombe
2011-07-25 20:19 ` Steven Rostedt
2011-07-25 20:28 ` Arnaud Lacombe
2011-07-25 22:38 ` Arnaud Lacombe
2011-07-25 23:49 ` Steven Rostedt
2011-07-25 23:52 ` Arnaud Lacombe
2011-07-26 0:14 ` Steven Rostedt
2011-07-25 23:50 ` Arnaud Lacombe
2011-07-25 23:58 ` Arnaud Lacombe
2011-07-26 0:08 ` Steven Rostedt
2011-07-26 0:35 ` Steven Rostedt
2011-07-26 0:44 ` Ian Lance Taylor
2011-07-26 0:41 ` Ian Lance Taylor
2011-07-26 1:08 ` Arnaud Lacombe
2011-07-26 1:12 ` Steven Rostedt
2011-07-26 1:19 ` Arnaud Lacombe
2011-07-26 20:43 ` Jeff Law [this message]
2011-07-26 1:10 ` Steven Rostedt
2011-07-26 5:55 ` Ian Lance Taylor
2011-07-26 12:00 ` Paulo Marques
2011-07-26 13:18 ` Jesper Juhl
2011-07-26 13:32 ` Paulo Marques
2011-07-26 13:55 ` Steven Rostedt
-- strict thread matches above, loose matches on Subject: below --
2011-07-18 9:35 stufever
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=4E2F270C.7020100@redhat.com \
--to=law@redhat.com \
--cc=fweisbec@gmail.com \
--cc=gcc-help@gcc.gnu.org \
--cc=iant@google.com \
--cc=lacombar@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
--cc=stufever@gmail.com \
--cc=wangshaoyan.pt@taobao.com \
/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