https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99997
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Component|c |tree-optimization Last reconfirmed| |2021-04-12 Keywords| |missed-optimization Status|UNCONFIRMED |ASSIGNED --- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> --- We expand from _10 = (_Bool) _9; if (_10 != 0) goto <bb 4>; [50.00%] else goto <bb 3>; [50.00%] ;; succ: 4 ;; 3 ;; basic block 3, loop depth 0 ;; pred: 2 _3 = page_2(D)->compound_head; _4 = (_Bool) _3; _11 = (int) _4; ;; succ: 4 ;; basic block 4, loop depth 0 ;; pred: 2 ;; 3 # iftmp.0_5 = PHI <1(2), _11(3)> _6 = (_Bool) iftmp.0_5; return _6; and what's obvious to see is that there are excessive conversions on 3->4. There's the opportunity to constant fold the _6 = (_Bool) iftmp.0_5 conversion on 2->4 by adjusting the type of iftmp.0_5 pushing another required conversion on the 3->4 edge which should nicely combine with the conversions already present there. At -O2 PRE performs this, at -O1 the same issue is present. Note the & 1 truncations are inserted by RTL expansion and since we lack partial DCE / sink on RTL it doesn't get optimized. I'll look into the GIMPLE simplification.