https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96237
Bug ID: 96237
Summary: Failure to recognize and pattern composed of and+or
after shift
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 char f(unsigned char x)
{
auto a = (x >> 3) & 1;
if (x & 16)
a |= 2;
if (x & 32)
a |= 4;
return a;
}
This can be optimized to `return (x >> 3) & 7;`. This transformation is done by
LLVM, but not by GCC.