https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110262
Bug ID: 110262 Summary: `t < 0 ? 1 : min(t, 1)` is not simplified down to just `t != 0` Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Take: ``` int g(int min_need_stall) { return min_need_stall < 0 ? 1 : ((min_need_stall) < (1) ? (min_need_stall) : (1)); } ``` This should just be the same as `min_need_stall != 0` but currently is not. Yes this code does shows up in real code, it is from sel-sched.cc: min_need_stall = min_need_stall < 0 ? 1 : MIN (min_need_stall, 1); Note we currently miscompile it but that is due to PR 110252 (which I have a fix).