https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94789
Bug ID: 94789
Summary: Failure to take advantage of shift operand semantics
to turn subtraction into negate
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 r(int x, unsigned b)
{
int const m = CHAR_BIT * sizeof(x) - b;
return (x << m);
}
`CHAR_BIT * sizeof(x) - b;` can be optimized to `-b`. LLVM does this
transformation, not GCC.
Comparison here : https://godbolt.org/z/5byJ2E