Newsgroups: comp.arch Path: csiph.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!kithrup.com!mrs From: mrs@kithrup.com (Mike Stump) Subject: Re: The freedom that give us C++ and C Message-ID: Date: Thu, 11 Feb 2016 06:07:43 GMT References: Organization: Kithrup Enterprises, Ld. X-Newsreader: trn 4.0-test77 (Sep 1, 2010) Lines: 36 Xref: csiph.com comp.arch:33620 In article , MitchAlsup wrote: >On Monday, February 8, 2016 at 5:59:14 PM UTC-6, Walter Banks wrote: >long winded Question: > >My understanding of volatile is that it "roughly" means "don't optimize >the loads and stores away" to a classical RISC machine. > >My understanding still allows the original problem of:: > >..........x = ++a; > >To be coded selected and scheduled into: > >.....LD.....R7,[A] >.....ADD....R8,R7,1 >.....ST.....R8,[X] >.....St.....R8,[A] > >Does it not? So, the usual interesting points would be does it generate an atomic add of 1 to memory or not? atomic_add_new R7,[A],1 st R7,[X] Does it is fetch from memory, the value from memory for the assignment to x? ld R7,[A] add R8,R7,1 st R8,[A] ld R9,[A] st R9,[X] Does the store to x happen _after_ the store to a? Does it do the same thing in C++ as it does in C?