Landing: db3b32439f9c

Project / Subsystem

gcc / middle-end

Date

2026-08-23

Author

Dominic P

Commit

db3b32439f9c8e98cea5625b9026cc42fd066917

Source

github

Perf win

Yes

Breaking

No

All attributes

project
gcc
subsystem
middle-end
patch_id
—
commit_hash
db3b32439f9c8e98cea5625b9026cc42fd066917
source_type
github
headline
Avoid spurious volatile load before bit-field store
tldr
Fixes a bug where volatile bit-field stores incorrectly emitted a read-modify-write cycle.
author
Dominic P
outcome
committed
performance_win
true
breaking_change
false
series_id
gcc:middle-end: don't read a memory destination fully overwritten by a bit-field store [pr71048]
series_parts
[]
tags
  • • optimization
  • • volatile
  • • embedded
discussion_id_link
—
bugzilla_pr
—
date
2026-08-23T00:00:00.000Z

When storing to a bit-field that occupies an entire memory unit, the compiler previously emitted a read of the memory destination before the write, even if no surrounding bits needed preserving. For non-volatile destinations, this read was optimized away, but for volatile destinations, it remained as a spurious memory access. This change modifies the store operation to directly write the value when the bit-field fills the entire unit, eliminating the unnecessary volatile read and preventing incorrect behavior with memory-mapped I/O registers that have side effects on reads.