https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103354
Bug ID: 103354 Summary: missed optimization with & and | and compares Product: gcc Version: 12.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 h(int a, int b, int c, int d) { return (c & -(a==b)) | (d & -(a!=b)); } ---- CUT --- We currently don't optimize the above down to just: int h(int a, int b, int c, int d) { return (a==b) ? c : d; } This is from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92342#c4