https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103216
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |TREE --- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> --- So this is almost fixed on the trunk at -O2: d_4 = (signed char) a_2(D); if (d_4 < 0) goto <bb 4>; [41.00%] else goto <bb 3>; [59.00%] <bb 3> [local count: 633507680]: _6 = (signed char) a_2(D); <bb 4> [local count: 1073741824]: # prephitmp_8 = PHI <_6(3), d_4(2)> The only thing missing is seeing that d_4 and _6 are the same ... Maybe factor_out_conditional_operation could detect this ... d_4 = (signed char) a_2(D); if (d_4 < 0) goto <bb 4>; [41.00%] else goto <bb 3>; [59.00%] <bb 3> [local count: 633507680]: _6 = (signed char) a_2(D); <bb 4> [local count: 1073741824]: # prephitmp_8 = PHI <_6(3), d_4(2)> factor_out_conditional_operation could factor out the cast to the definition of d_4 ... Anyways the original code is now optimized (via RTL level) so maybe it is not as important.