https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94920
Bug ID: 94920
Summary: Failure to optimize abs pattern from arithmetic with
selected operands based on comparisons with 0
Product: gcc
Version: 11.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 f(int x)
{
return (x >= 0 ? x : 0) + (x <= 0 ? -x : 0);
}
This can be optimized to `return abs(x)`. LLVM does this transformation, but
GCC does not.