https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105983
Bug ID: 105983 Summary: Failure to optimize (b != 0) && (a >= b) as well as the same pattern with binary and Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: gabravier at gmail dot com Target Milestone: --- bool f(unsigned a, unsigned b) { return (b != 0) && (a >= b); } This can be optimized to `return (b != 0) & (a >= b);`, which is itself optimized to `return (b - 1) > a;`. GCC outputs code equivalent to `return (b != 0) & (a >= b);` (at least on x86) whereas if that code is compiled it would output `return (b - 1) > a;`, while LLVM has no trouble directly outputting the optimal code.