https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106161
--- Comment #2 from Victor Luchitz <vluchits at gmail dot com> --- Created attachment 53234 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53234&action=edit Test case Minimal test case. You can see in the disassembly the same pattern as described in the original report. First gcc tests for individual bitflags on the "actionbits" variable and stores results on the stack for each individual bitflag: 7c: 60 b3 mov r11,r0 7e: c9 10 and #16,r0 80: 1f 0e mov.l r0,@(56,r15) 82: 60 b3 mov r11,r0 84: c9 01 and #1,r0 86: 1f 0f mov.l r0,@(60,r15) Then performs tests after fetching them from memory: 112: 50 fd mov.l @(52,r15),r0 114: 20 08 tst r0,r0 116: 8f 01 bf.s 11c <_R_SegLoop+0x11c> 118: 50 fe mov.l @(56,r15),r0 11a: 62 83 mov r8,r2 11c: 20 08 tst r0,r0 11e: 8f 02 bf.s 126 <_R_SegLoop+0x126> It would make more sense to keep the value of 'actionbits' in a register and perform tst #imm,r0 instead.