GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc/i386

i386: Don't split volatile memory tests into 8-bit tests.

Avoids undesirable splitting of 16/32-bit volatile memory tests into 8-bit tests when `-ffuse-ops-with-volatile-access` is enabled.

When -ffuse-ops-with-volatile-access is enabled, the compiler could split 16 or 32-bit volatile memory tests into 8-bit volatile memory tests. This change prevents this splitting, as it can lead to misbehavior, especially when accessing memory-mapped hardware registers. A new test case is added to verify the fix.

In Details

The i386 backend's HI/SI test -> QI test splitter in i386.md could, with -ffuse-ops-with-volatile-access, transform a volatile memory access of 16 or 32 bits into a series of 8-bit accesses. This is problematic for memory-mapped hardware registers where the access width and atomicity are significant. The patch avoids the split if the operand is a volatile MEM.

For Context

In GCC, volatile memory accesses are those that must occur exactly as specified in the code, without optimization. This is important when interacting with hardware or memory locations that have side effects. This commit prevents the compiler from splitting larger volatile memory accesses into smaller ones on i386, which could lead to unexpected behavior when dealing with hardware registers or other special memory locations. The -ffuse-ops-with-volatile-access option controls a class of optimizations related to combining operations with volatile accesses. The i386 target uses a collection of .md files to describe the instruction set and how to translate operations into that instruction set.

Filed Under: i386volatileoptimization