This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


On Mon, Jul 02, 2007 at 10:17:13AM -0700, Ian Lance Taylor wrote:
> volatile uint32_t* ptr = .....;
> uint32_t v = *ptr;
> v = (v & 0xffffff00) | 123;
> *ptr = v;
> 
> Note that if you don't use the volatile qualifier, gcc is wholly
> capable of optimizing that into an 8-bit memory write.

   Or more precisely, it used to, and we intend it to regain that capability
in the future. See bug 15184.

   When it comes to a back end solution, one existing target (MT) has an
option to not generate byte loads and stores, and there was a long thread
about modifying the ARM back end to generate byte writes such that, at the
hardware level, they would become a cache line wide read-modify-write
access. Search the GCC mailing list for this:

Modifying ARM code generator for elimination of 8bit writes - need help

   The ARM solution relies on assistance form the hardware, so I suggest you
look at the MT back end first to see if it does something clever.

-- 
Rask Ingemann Lambertsen


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]