Re: problems with "reordered code" using GNU, PPC, vxWorks

mcintosh@mc-pc.research.telcordia.com (Allen McIntosh)
30 Mar 2003 00:35:25 -0500

          From comp.compilers

Related articles
problems with "reordered code" using GNU, PPC, vxWorks schulze_wolfgang@t-online.de (2003-03-24)
Re: problems with "reordered code" using GNU, PPC, vxWorks mcintosh@mc-pc.research.telcordia.com (2003-03-30)
Re: problems with "reordered code" using GNU, PPC, vxWorks anton@mips.complang.tuwien.ac.at (2003-03-30)
Re: problems with "reordered code" using GNU, PPC, vxWorks mrmnews@the-meissners.org (Michael Meissner) (2003-03-30)
| List of all articles for this month |
From: mcintosh@mc-pc.research.telcordia.com (Allen McIntosh)
Newsgroups: comp.compilers
Date: 30 Mar 2003 00:35:25 -0500
Organization: none
References: 03-03-151
Keywords: optimize, C
Posted-Date: 30 Mar 2003 00:35:25 EST

Wolfgang Schulze <schulze_wolfgang@t-online.de> wrote:
>I´m using a PPC under vxworks, Ansi C, GNU. After compilation my code
>is reordered for optimisation. I want to have my code optimized by the
>compiler, but in some source code I need to have the exact instruction
>order as I write in my source code.


You could try turning peephole optimization off (I think there is a
gcc option for this) for the critical files, or turning optimization
off altogether.


The C standard gives the compiler some latitude in re-ordering
operations. There is not a whole lot you can do about it, unless the
compiler gives you something like "noreorder".


>[Isn't that what volatile declarations are supposed to do? -John]


Good question.


volatile int a;
volatile int b;
a+b


Must the compiler fetch a before b? It's been a looong time since
I did this sort of thing, so I'll defer to anyone who has read
the standard recently.
[No, because + isn't a sequence point. But this is sequenced:
int t;
t = a; /* semicolon is sequence point */
t += b;
- John]



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.