https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104339
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Status|UNCONFIRMED |ASSIGNED Last reconfirmed| |2022-02-02 --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- I have a fix which I will be submitting once GCC 13 opens up. Basically for factor_out_conditional_conversion instead of checking dominatation, check to see if the cast is only used in the PHI. This allows us to take: y_5 = -y_2(D); yy_6 = (int) y_5; if (y_2(D) != 0) goto <bb 3>; [INV] else goto <bb 4>; [INV] <bb 3> : <bb 4> : # tt_1 = PHI <0(2), yy_6(3)> And and factor out the cast in phiopt1 and then allows us to change the whole if to a straight line of -y_2(D). >From phiopt1 with details: PHI tt_1 changed to factor conversion out from COND_EXPR. New stmt with CAST that defines tt_1. Removing basic block 3 ;; basic block 3, loop depth 0 ;; pred: 2 ;; succ: 4 COND_EXPR in block 2 and PHI in block 4 converted to straightline code. Merging blocks 2 and 4 fix_loop_structure: fixing up loops for function