https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94783
Bug ID: 94783 Summary: Abs-equivalent pattern is not recognized as abs 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: --- unsigned r(int v) { const int mask = v >> (sizeof(int) * CHAR_BIT - 1); return (v + mask) ^ mask; } This can be optimized to `return abs(v)`. This transformation is done by LLVM, not by GCC. Comparison here : https://godbolt.org/z/4rduiJ