From mboxrd@z Thu Jan 1 00:00:00 1970 From: Roger Racine To: Peter Barada Cc: crossgcc@sources.redhat.com Subject: Re: PowerPC and Volatile Date: Tue, 05 Dec 2000 04:14:00 -0000 Message-id: <4.2.0.58.20001204153756.0143c610@popx.draper.com> References: <4.2.0.58.20001201145105.0126e130@popx.draper.com> <200012012055.PAA19861@hyper.wm.sps.mot.com> X-SW-Source: 2000-12/msg00015.html At 03:55 PM 12/1/2000 , Peter Barada wrote: > >Naturally, the locations we are talking about are declared volatile, so the > >compiler does not optimize the code, but the PowerPC has its own > >optimization in the form of pipelining, and it seems to be causing this > >problem. > > > >The question is, should the compiler be inserting an "eieio" instruction at > >the sequence points in the code, such as the end of the loop mentioned > >above? This PPC instruction tells the processor to hold off its > >pipelining. We have been inserting them in the code ourselves, but it is a > >bit of a pain to have to do it. > >No, the compiler can't automatically insert eieio instructions >since it doesn't know which pairs of *locations* need to have the eieio >synchronization. That is something that only the hardware knows >about. If it automatically put in an eieio before every volatile >reference, then it would uncecessarily slow down all volatile >accesses, even those between volatile locations that *don't* require it. > >I understand that its a pain, but when dealing with memory mapped i/o >devices and high performance processors, its part of the price you pay >for the gain in speed. I have a book titled "C A Reference Manual", by Samuel P. Harbison and Guy L. Steele Jr. In section 4.4.5, they say the following: " To be more precise, ISO C introduces the notion of sequence points in C programs. A sequence point exists at the completion of all expressions that are not part of a larger expression--that is, at the end of expression statements, control expressions if, switch, while, and do statements, each of the three control expressions in the for statement, return statement expressions, and initializers. Additional sequence points are present in function calls immediately after all the arguments are evaluated, in the logical AND (&&) and OR (||) expressions, and before the conditional operator (?:) and the comma operator (,). References to and modifications of volatile objects must not be optimized across sequence points, although optimizations between sequence points are permitted." Based on this (I do not have the ISO C Standard to check), there -are- known locations at which the eieio instructions could be (and should be, to my reading) inserted. Based on the answers I have received, it appears that this is not a case of using an old version of the compiler, which has been corrected in a later version; I will have to do it manually. Roger Racine Draper Laboratory, MS 31 555 Technology Sq. Cambridge, MA 02139, USA 617-258-2489 617-258-3939 Fax ------ Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/ Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com