https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111698
Bug ID: 111698 Summary: Narrow memory access of compare to byte width Product: gcc Version: 12.3.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: ubizjak at gmail dot com Target Milestone: --- Following testcase: --cut here-- int m; _Bool foo (void) { return m & 0x0f0000; } --cut here-- compiles to: 0: f7 05 00 00 00 00 00 testl $0xf0000,0x0(%rip) 7: 00 0f 00 The test instruction can be demoted to byte test from addr+2. Currently, the demotion works for lowest byte, so the testcase: --cut here-- int m; _Bool foo (void) { return m & 0x0f; } --cut here-- compiles to: 0: f6 05 00 00 00 00 0f testb $0xf,0x0(%rip) which is three bytes shorter. Any half-way modern Intel and AMD cores will forward any fully contained load, so there is no danger of forwarding stall with recent CPU cores.