Can I force a word read-modify-write instread of a byte write?

Ian Lance Taylor iant@google.com
Mon Jul 2 16:55:00 GMT 2007


"Phil Endecott" <spam_from_gcc_help@chezphil.org> writes:

> I know that in some circumstances gcc will generate read-modify-write
> sequences to access memory locations, for example if I have a bitfield
> struct.  Is there a way in which I can tell it to only do (32-bit)
> word writes to a region of memory, and to do read-modify-write
> sequences instead of byte writes, even though the processor does have
> byte write instructions?

Sure, this is what the volatile qualifier is for.  If you always
access the memory through volatile qualified pointers, the compiler
will always access the memory precisely as you write in the program.

This is one of the few cases where volatile is actually useful.

Ian



More information about the Gcc-help mailing list