Search

A technology, a device or an article

A CPU load can wait for a store while the cache stays hot

A hot L1 does not remove a load’s dependence on a pending store. Overlapping byte ranges explain store forwarding and what a meaningful experiment must preserve.

Two rows of paper tiles with red and blue inserts joined by a bridge
ITNWS AI-generated conceptual illustration. The bridge evokes forwarding from a store to a load; this is not a CPU schematic.ITNWS · image_gen · Original ITNWS AI-generated conceptual editorial illustration

The missing cache miss is the useful clue. Suppose a short calculation repeatedly writes a temporary value and immediately reads an overlapping region. The working data fits comfortably in L1, yet changing the widths of those accesses changes the time of a dependent calculation. Buying a larger cache would answer a question the example has not asked. Before explaining the difference through memory bandwidth, we need to examine how a younger load obtains bytes that an older store has not yet delivered to the cache.

This is a proposed experiment, not a report of measurements. No processor was benchmarked for this article. Its purpose is to identify a mechanism and the observations that could distinguish it from competing explanations. The Intel optimization reference, historical revision 050, discusses store forwarding and its restrictions. The revision is not a promise that every current CPU has the same restrictions or penalty. It supplies a reason to investigate the relationship between accesses rather than treating every memory operand as an independent trip to L1. Sources were checked on October 29, 2026.

A store has more work to do than produce a value. Its address and data must become available, architectural rules must permit it to take effect, and the memory system must accept the resulting update. A processor can retain pending stores while continuing useful execution. If a subsequent load needs data supplied by one of those stores, waiting for the full cache update would often be wasteful. Store-to-load forwarding offers a shorter internal route: the pending store supplies the needed value directly to the load.

The important relationship is age within one instruction stream. This is not a promise that another core can immediately read an unpublished store, and it is not a replacement for synchronization between threads. The processor must preserve the program’s architectural meaning even while it uses internal shortcuts. Forwarding describes where a load may obtain its data during that execution. An application cannot turn the mechanism on by naming a variable local, nor can it infer another thread’s visibility from successful forwarding in its own thread.

The bytes are the experiment

Imagine an aligned eight-byte region beginning at address p. In one hypothetical machine-code sequence, an eight-byte store writes p through p+7, and a following eight-byte load reads exactly that range. The pending store contains all the bytes that the load needs. In another sequence, a four-byte store writes p through p+3, followed by an eight-byte load from p. Half the requested range comes from the recent store; the other half must preserve the region’s earlier contents. Both sequences can operate on a hot cache line, but they present different tasks to the forwarding machinery.

The second sequence is not automatically an incorrect program. Its complete result can be well defined if the surrounding code initializes the other bytes and respects the language’s object and aliasing rules. It is simply less convenient for a mechanism designed to forward a compatible stored value. The CPU may need to wait or recover through a slower path. Which arrangements qualify for forwarding, and how expensive the alternatives are, depend on the microarchitecture. A byte diagram predicts a question to ask; it does not measure a universal cycle count.

A narrower load entirely inside a wider store is another case. It should not be lumped together with a load that extends past the store’s end. Yet complete containment alone is not a portable certificate of the fastest behavior: alignment, boundaries, supported widths and implementation details still matter. Intel’s historical discussion specifically distinguishes size and alignment requirements from the availability of store data. That distinction is more useful than a slogan saying that every mismatch is slow. Two superficially similar mismatches can exercise different conditions.

The address calculation can also be late. If the processor does not yet know where an older store will write, it cannot establish the relationship with every ready younger load by looking at completed addresses alone. Memory disambiguation predicts whether execution can safely proceed. The Intel description of speculative hardware behavior explains that an overlapping store discovered after a speculative load can require re-execution. That is related to memory dependencies but distinct from an already identified, compatible store forwarding its data.

The same document discusses a fast store forwarding predictor on certain processors. Its existence is another reason not to collapse the topic into a single timeless diagram. A speculative prediction about which store supplies a load must still be checked against correctness. An incorrect speculative result must not become the committed architectural result. For the performance investigator, this means that a result can reflect prediction and recovery as well as the final byte relationship. It does not authorize a claim that speculative intermediate values are legitimate application outputs.

Pencil drawing of two compartment trays with a transparent window over the upper tray
ITNWS AI-generated conceptual illustration. The window evokes complete coverage of requested bytes; dimensions do not encode device parameters. — ITNWS · image_gen · Original ITNWS AI-generated conceptual editorial illustration

Now make the result dependent. If each iteration consumes the preceding load’s result to form its next useful value, a delay in obtaining that load can lie directly on the critical path. If many unrelated operations run alongside it, some waiting may be hidden. Therefore, the same access geometry can have a different effect on total application time without the forwarding mechanism itself changing. The experiment must state whether it examines a dependency chain or sustained throughput of independent work. Substituting one for the other changes what the measured duration means.

It is equally important not to introduce a second cache line by accident. Moving an address while changing access width can cross a line or page boundary, adding another possible explanation. If the proposed comparison is about store overlap, the test should initially keep unrelated boundaries and working-set placement comparable. Later, a deliberately changed boundary can become a separate experiment. An uncontrolled change cannot be rescued by a confident explanation after the result appears. The useful object is an interpretable comparison, not merely a large difference.

The compiler may remove the question

At source level, writing a value and immediately reading the same variable looks like the right experiment. An optimizing compiler may correctly keep the value in a register, merge accesses, or eliminate the load. The source then describes an operation that the processor never performs. The GCC optimization options document transformations whose availability depends on optimization settings. Consequently, reviewing the emitted machine code is part of establishing that a forwarding experiment exists at all. It is not an optional detail appended after timing.

Using volatile indiscriminately is not a complete solution. It changes the language-level access requirements and can inhibit transformations, but it does not make every chosen object representation or alias legal. Nor does it establish the exact instruction widths on every target. A meaningful low-level experiment needs a defined construction and a verified binary. If inline assembly is used, its memory operands, clobbers and dependencies must accurately describe the work to the compiler. An experiment that accidentally permits reordering outside its stated boundaries cannot establish a reliable latency claim.

The comparison should also avoid smuggling a different numerical algorithm into one version. Replacing partial stores with a full-width store can change untouched bytes unless those bytes are deliberately preserved or their values are immaterial. Replacing a reload with a register value may be an excellent optimization, but only when it preserves the required semantics. This is why a suggested optimization should be explained in terms of the data actually needed. “Use wider stores” is not a substitute for showing that the wider write is valid.

Consider a packed record assembled in pieces and then consumed as one machine word. Its layout might save space while creating an awkward forwarding relationship. That does not prove the packed layout is a poor design overall. More compact records could reduce cache misses elsewhere, improve transfer efficiency, or be required by an external format. The local store/load cost has to be weighed in the workload that uses the record. A microbenchmark can isolate a mechanism; it cannot decide every trade-off made by the application that contains it.

There is another tempting shortcut: adding a fence. Ordering instructions serve architectural purposes; they do not manufacture missing store bytes or make an incompatible forwarding pattern compatible. They can instead add waiting and remove useful overlap. If a program requires ordering, that requirement must be satisfied independently. If it is already correct and the question is the source of a performance difference, an added fence changes the experiment. A faster or slower result after that change needs a new explanation rather than being called proof of the original hypothesis.

Counters can strengthen an investigation when their definitions fit the processor. A generic cache-miss count does not name every reason a load waits. A model-specific event associated with blocked loads or forwarding restrictions may be informative, but its availability and exact meaning must be established on that model. The perf stat manual also explains practical issues such as repeated runs and counter multiplexing. A scaled count from a partly scheduled event is different evidence from a continuously counted event, particularly in a very short experiment.

A useful report would preserve the instruction sequence, CPU model, relevant environment, timing boundaries and event definitions. That information is not paperwork separate from the result: it defines the claim. If changing a compiler version changes a load into a register move, the experiment’s subject has changed. If the measured region includes initialization in one case, the comparison has changed. If the processor is interrupted, elapsed time can change without the byte forwarding rule changing. Repetition helps describe variation; it does not automatically identify its cause.

The broader program can offer a better optimization than repairing the memory round trip. A temporary value that never needs an address can remain in a register. A producer and consumer can share a representation that avoids immediate partial reconstruction. Batching may separate stores and dependent reloads enough for the relationship to change. Each possibility must preserve observable behavior and be evaluated against the actual bottleneck. The point is to remove unnecessary work where justified, not to imitate one favorable instruction sequence everywhere.

This mechanism concerns data delivery inside one CPU core after a store. SIMD alignment determines whether and how a particular address suits an instruction; inter-core publication determines what another participant may observe. Those subjects can meet in the same program without becoming the same guarantee. Keeping their questions separate makes the explanation more precise: hot data can still have an unresolved dependency, and legal access can still have an inconvenient internal path.

The experiment can now earn its interpretation. A controlled change in overlap, verified in machine code and accompanied by suitable observations, could support a store-forwarding explanation. A simultaneous change in access boundaries, instruction count or dependency structure would leave competing explanations alive. The missing cache miss was never evidence that nothing was waiting. It was a reason to ask which earlier store had the bytes, whether it had all of them, and what the younger load had to wait for before the calculation could continue.

Sources & documentation

  1. Intel Optimization Reference Manual volume1 revision050 (historical) ↗
  2. Intel hardware behavior related to speculative execution ↗
  3. GCC optimize options ↗
  4. Linux perf stat manual ↗