https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102402
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Component|target |tree-optimization Last reconfirmed| |2021-09-18 Status|UNCONFIRMED |NEW --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Confirmed, note the best code is generated by: void ClearModM1(struct MusicPlayerTrack *track, uint8_t modT) { int t =0; if (track->modT == 0) t = 3; else t = 12; track->flags |= t; } This is then a gimple level issue where: if (_1 == 0) goto <bb 3>; [50.00%] else goto <bb 4>; [50.00%] <bb 3> [local count: 536870913]: _3 = pretmp_6 | 3; goto <bb 5>; [100.00%] <bb 4> [local count: 536870913]: _5 = pretmp_6 | 12; <bb 5> [local count: 1073741824]: # cstore_12 = PHI <_3(3), _5(4)> is not transformed into: if (track->modT == 0) t = 3; else t = 12; cstore_12 = pretmp_6 | t; There is also a sinking issue though I don't know if has a wider effect (and does not matter in this case really). Take: void ClearModM1(struct MusicPlayerTrack *track, uint8_t modT) { int t =0; int t2 = track->modT; int t1 = track->flags; if (t2 == 0) t = 3; else t = 12; track->flags = t1|t; } The load for track->flags is not sunk after the if.