https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61839
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |missed-optimization Status|UNCONFIRMED |NEW Last reconfirmed| |2014-07-23 Summary|More optimize opportunity |More optimize opportunity | |for VRP Ever confirmed|0 |1 Known to fail| |4.10.0 --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- Confirmed. This is straight-line (A) code vs. if-code (B) that makes the difference, introduced by fold already: --- a/t.c.003t.original 2014-07-23 14:48:48.984335370 +0200 +++ b/t.c.003t.original 2014-07-23 14:46:19.224345681 +0200 @@ -11,7 +11,7 @@ int a = -1; volatile unsigned int b = 1; int c = 1; - c = b != 0 ? 486097858 : 972195717; + c = a + 972195718 >> (b != 0); if (c == 486097858) { (void) 0; in the bad case we have <bb 2>: b ={v} 1; b.0_3 ={v} b; _4 = b.0_3 != 0; _5 = (int) _4; c_6 = 972195717 >> _5; if (c_6 == 486097858) ... until the very end, not transforming c_6. Note that VRP could do the missing transform as it knows that _5 is [0, 1] (it has to jump through the shift - the value-range for the shift itself is too broad). If written this kind of transform should be applied more generally, not just for shifts. It basically wants to ask whether a conditional test can be carried out against another SSA name (and another constant) if an intermediate compute can be omitted in that case.