https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95532
Bug ID: 95532 Summary: Failure to optimize __builtin_ctz & 0x1F to __builtin_ctz on x86 with BMI Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: gabravier at gmail dot com Target Milestone: --- int f(int x) { return __builtin_ctz(x) & 0x1F; } With -mbmi, this can be optimized to `__builtin_ctz(x)` (directly using `tzcnt` without an `and` afterwards). This transformation is done by LLVM, but not by GCC.