https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71336
--- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> --- On a related note I noticed the final code for int test(int a) { return (a & CST) * 4 + 3; } is not optimal when CST is a power of two, e.g. when CST=8: _Z4testi: .LFB0: .cfi_startproc andl $8, %edi leal 0(,%rdi,4), %eax addl $3, %eax ret The leal and the addl could be combined into a single leal. When CST is not a power of two then there is no addl.