https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94785
Bug ID: 94785
Summary: Failure to detect abs pattern using multiplication
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)
{
return (1 | -(v < 0)) * v;
}
`r` is equivalent to `abs(v)`. GCC does not make the transformation to an
`abs`.
Example of the optimization not being done : https://godbolt.org/z/Rw-hBt