https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106245
Bug ID: 106245 Summary: Failure to optimize (u8)(a << 7) >> 7 pattern to a & 1 Product: gcc Version: 13.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: --- #include <stdint.h> int8_t f(int8_t a) { return (uint8_t)(a << 7) >> 7; } This can be optimized to `return a & 1;`. This transformation is done by LLVM, but not by GCC.