https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122563
Bug ID: 122563
Summary: Redundant computation around x & (-x)
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: fxue at os dot amperecomputing.com
Target Milestone: ---
"x & (-x)" is to get a value of power of 2, (or zero value), which has same LSB
as "x". Any prior computation that does not change LSB, is redundant regarding
to the expression "x & (-x)", for example:
int foo(int x, int m, int n)
{
x *= (2 * m + 1); // could be eliminated
x |= x << n; // could be eliminated
return x & (-x);
}