http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46091
Summary: missed optimization: x86 bt/btc/bts instructions Product: gcc Version: 4.3.5 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target AssignedTo: unassig...@gcc.gnu.org ReportedBy: jay.kr...@cornell.edu The following code, at least when optimizing for space, should use x86 bt/btc/bts instructions. #include <limits.h> #include <stddef.h> void set_bit(size_t* a, size_t b) { const unsigned c = sizeof(size_t) * CHAR_BIT; a[b / c] |= (((size_t)1) << (b % c)); } void clear_bit(size_t* a, size_t b) { const unsigned c = sizeof(size_t) * CHAR_BIT; a[b / c] &= ~(((size_t)1) << (b % c)); } int get_bit(size_t* a, size_t b) { const unsigned c = sizeof(size_t) * CHAR_BIT; return !!(a[b / c] & (((size_t)1) << (b % c))); }