|problems with "reordered code" using GNU, PPC, vxWorks email@example.com (2003-03-24)|
|Re: problems with "reordered code" using GNU, PPC, vxWorks firstname.lastname@example.org (2003-03-30)|
|Re: problems with "reordered code" using GNU, PPC, vxWorks email@example.com (2003-03-30)|
|Re: problems with "reordered code" using GNU, PPC, vxWorks firstname.lastname@example.org (Michael Meissner) (2003-03-30)|
|From:||email@example.com (Anton Ertl)|
|Date:||30 Mar 2003 00:36:47 -0500|
|Organization:||Institut fuer Computersprachen, Technische Universitaet Wien|
|Posted-Date:||30 Mar 2003 00:36:47 EST|
firstname.lastname@example.org (Wolfgang Schulze) writes:
>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.
>After I have disassembled the compiled code, I register that nearly
>all c-code lines are mixed (reordered). For the MIPS there is a switch
>"noreorder". Is there a similar switch for the PPC architecture?
No, but then AFAIK PPC assemblers don't reorder anyway. Your
reordering is probably coming from the compiler.
>What have I to do to avoid unwished code reordering during otimisation
As our moderator suggests, ANSI C volatile could give you what you
want (potentially at a high cost in run-time).
If your problem is aliasing between different pointer types, changing
the types involved into "char *" would also fix the problem
(alternatively, use gcc's -fno-strict-aliasing or similar options for
Alternatively, you can ask the compiler not to schedule code. If you
use gcc, -fno-delayed-branch -fno-schedule-insns -fno-schedule-insns2
might do the job.
Finally, if you use gcc, and are not commited to sticking to ANSI C,
gcc will not move 'asm("");' across other code (except "in ways that
appear insignificant to the compiler, such as across jump
instructions"), and it therefore acts as a scheduling barrier between
the code before and the code after.
M. Anton Ertl
Return to the
Search the comp.compilers archives again.