https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111294
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- The difference is jump threading: old (able to remove foo): ``` Registering killing_def (path_oracle) _4 Registering value_relation (path_oracle) (_4 pe8 _33) (root: bb5) Checking profitability of path (backwards): [1] Registering jump thread: (5, 7) incoming edge; (7, 9) nocopy; path: 5->7->9 SUCCESS ``` vs new (not able to remove foo): ``` Registering killing_def (path_oracle) _33 Registering value_relation (path_oracle) (_33 pe8 _31) (root: bb5) Checking profitability of path (backwards): FAIL: Jump-thread path not considered: duplication of 2 insns is needed and optimizing for size. path: 5->7->xx REJECTED ``` Old IR before jump threading: ``` <bb 5> [local count: 118111600]: a.9_28 = a; if (a.9_28 != 0) goto <bb 6>; [34.00%] else goto <bb 7>; [66.00%] <bb 6> [local count: 40157944]: _30 = (char) b.1_2; <bb 7> [local count: 118111600]: # _33 = PHI <_30(6), 0(5)> _4 = (unsigned char) _33; _6 = (int) a.9_28; j_22 = (short int) _4; _20 = (int) _4; if (_4 > 11) goto <bb 8>; [50.00%] else goto <bb 9>; [50.00%] ``` New: ``` <bb 5> [local count: 118111600]: a.9_28 = a; if (a.9_28 != 0) goto <bb 6>; [34.00%] else goto <bb 7>; [66.00%] <bb 6> [local count: 40157944]: <bb 7> [local count: 118111600]: # _31 = PHI <b.1_2(6), 0(5)> _32 = (char) _31; _4 = (unsigned char) _31; _6 = (int) a.9_28; j_22 = (short int) _4; _33 = _31 & 255; if (_33 > 11) goto <bb 8>; [50.00%] else goto <bb 9>; [50.00%] ``` But _32 will be 0, _4 will be 0, j_22 will be 0, _33 will be 0. But I think jump threading does not recognize j_22 will be 0 on that edge and considers it a copy ... I think.