https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94916
Bug ID: 94916 Summary: Failure to optimize pattern into difference or zero selector Product: gcc Version: 10.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: --- int f(int x, int y) { return (x - y) & -(x >= y); } This can be optimized to return x >= y ? x - y : 0. LLVM does this transformation, but GCC does not. (also, GCC fails to optimize the resulting pattern properly, but this is already reported in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94898)