-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 09/27/11 03:34, Amker.Cheng wrote: > On Tue, Sep 27, 2011 at 1:12 PM, Miles Bader <miles@xxxxxxx> > wrote: >> Miles Bader <miles@xxxxxxx> writes: >>>> Hmm, actually testing with a recent gcc snapshot, it _is_ >>>> merging the two if-blocks: >>> ... >>> >>> and in fact, gcc 4.4.6, 4.5.3, and 4.6.1 seem to do the same >>> thing! >>> >>> So I dunno... what's the complaint again...? >> >> I note that this optimization only takes place at -O2 or above; >> maybe the original poster simply didn't use a high-enough >> optimization level? >> >> -miles >> >> -- I'd rather be consing. >> > > A case I ran into with gcc trunk after cprop1 pass: > > cc <- compare(r684, 0) if (cc != 0) goto .L1 r191 <- 0 goto .L2 > .L1: r191 <- 0 ...other insns .L2: > > In my experiment, both following pre and cse passes do not hoist > the r191<-0 to the beginning. I understand that it is actually not > a redundant case, and not pre's job. So which pass in gcc might > handle it? Thanks very much. > > Wondering is it a similar story to the original post? What you've described is code hoisting. pre and cse aren't going to perform this optimization because on any given path through the CFG only one r191<-0 statement will be executed. Typically this isn't going to be caught by block or tail merging due to "other insns". However, there is a code hoisting pass that is enabled by -Os which might catch this stuff. jeff -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBAgAGBQJOgfwlAAoJEBRtltQi2kC7t4QH/0jeYAjLu9iafjsnY/CRElMk ImkV8VNRJvbr4mYexI5JQoF63ZM3/LUwlfrU77UwLwEL/lbGt+i695UBmOX2UP2D Xqvhb9fQFAT57oYMOAKr2ohPWs12LiJK1bPRv3HoARJfXamLX4OFYFJsD2srHO+y dhNrEPQRfkn8jPWB2Ib7UtX48FZG0Oy4WWOqK8yPWk1RSW3eDSI8OEVXbSRaVMOC K8oj2QAnPy8EulwSD8E0kEo4f2IqOCiMpDy5qMY5yrDA1AQwYdu71WH1y0fOCmZj OnCCKK16fIxQQt3ifJAa9iE1H+U44O/DsIrbTS7Y5BMhQT4zFMaa8I8BVo0PGuc= =LadS -----END PGP SIGNATURE-----