https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102566
--- Comment #11 from Thiago Macieira <thiago at kde dot org> --- $ for ((i=0;i<32;++i)); do ~/dev/gcc/bin/gcc "-DCONSTANT=(1<<$i)" -S -o - -O2 /tmp/test.cpp | grep bts; done lock btsl $0, (%rdi) lock btsl $1, (%rdi) lock btsl $2, (%rdi) lock btsl $3, (%rdi) lock btsl $4, (%rdi) lock btsl $5, (%rdi) lock btsl $6, (%rdi) lock btsl $7, (%rdi) lock btsl $8, (%rdi) lock btsl $9, (%rdi) lock btsl $10, (%rdi) lock btsl $11, (%rdi) lock btsl $12, (%rdi) lock btsl $13, (%rdi) lock btsl $14, (%rdi) lock btsl $15, (%rdi) lock btsl $16, (%rdi) lock btsl $17, (%rdi) lock btsl $18, (%rdi) lock btsl $19, (%rdi) lock btsl $20, (%rdi) lock btsl $21, (%rdi) lock btsl $22, (%rdi) lock btsl $23, (%rdi) lock btsl $24, (%rdi) lock btsl $25, (%rdi) lock btsl $26, (%rdi) lock btsl $27, (%rdi) lock btsl $28, (%rdi) lock btsl $29, (%rdi) lock btsl $30, (%rdi) lock btsl $31, (%rdi) And after changing to long: $ for ((i=32;i<64;++i)); do ~/dev/gcc/bin/gcc "-DCONSTANT=(1L<<$i)" -S -o - -O2 /tmp/test.cpp | grep bts; done lock btsq $32, (%rdi) lock btsq $33, (%rdi) lock btsq $34, (%rdi) lock btsq $35, (%rdi) lock btsq $36, (%rdi) lock btsq $37, (%rdi) lock btsq $38, (%rdi) lock btsq $39, (%rdi) lock btsq $40, (%rdi) lock btsq $41, (%rdi) lock btsq $42, (%rdi) lock btsq $43, (%rdi) lock btsq $44, (%rdi) lock btsq $45, (%rdi) lock btsq $46, (%rdi) lock btsq $47, (%rdi) lock btsq $48, (%rdi) lock btsq $49, (%rdi) lock btsq $50, (%rdi) lock btsq $51, (%rdi) lock btsq $52, (%rdi) lock btsq $53, (%rdi) lock btsq $54, (%rdi) lock btsq $55, (%rdi) lock btsq $56, (%rdi) lock btsq $57, (%rdi) lock btsq $58, (%rdi) lock btsq $59, (%rdi) lock btsq $60, (%rdi) lock btsq $61, (%rdi) lock btsq $62, (%rdi) lock btsq $63, (%rdi) But: $ cat /tmp/test2.cpp #include <atomic> bool tbit(std::atomic<long> &i) { return i.fetch_or(1, std::memory_order_relaxed) & (~1); } $ ~/dev/gcc/bin/gcc -S -o - -O2 /tmp/test2.cpp .file "test.cpp" .text /tmp/test.cpp: In function ‘bool tbit(std::atomic<long int>&)’: /tmp/test.cpp:2:6: error: type mismatch in binary expression 2 | bool tbit(std::atomic<long> &i) | ^~~~ long int long unsigned int __int_type _9 = _6 & -2; during GIMPLE pass: fab /tmp/test.cpp:2:6: internal compiler error: verify_gimple failed 0x119fbba verify_gimple_in_cfg(function*, bool) /home/tjmaciei/src/gcc/gcc/tree-cfg.c:5576 0x106ced7 execute_function_todo /home/tjmaciei/src/gcc/gcc/passes.c:2042 0x106d8fb execute_todo /home/tjmaciei/src/gcc/gcc/passes.c:2096 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions.