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

anton@mips.complang.tuwien.ac.at (Anton Ertl)
30 Mar 2003 00:36:47 -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: anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.compilers
Date: 30 Mar 2003 00:36:47 -0500
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
References: 03-03-151
Keywords: optimize, C
Posted-Date: 30 Mar 2003 00:36:47 EST

schulze_wolfgang@t-online.de (Wolfgang Schulze) writes:
>Im 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
>process???


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
other compilers).


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.
- anton
--
M. Anton Ertl
anton@mips.complang.tuwien.ac.at
http://www.complang.tuwien.ac.at/anton/home.html


Post a followup to this message

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