optimization by as

Paul_Koning@Dell.com Paul_Koning@Dell.com
Mon Aug 17 14:37:00 GMT 2015


> On Aug 17, 2015, at 5:29 AM, Yury Gribov <y.gribov@samsung.com> wrote:
> 
> On 08/10/2015 05:53 PM, Paul_Koning@Dell.com wrote:
>> 
>>> On Aug 10, 2015, at 2:41 AM, Virendra Kumar Pathak <kumarvir.pathak@gmail.com> wrote:
>>> 
>>> Hi Andrew,
>>> 
>>> Thanks for the reply.
>>> 
>>> What other types of optimization can be handled by the assembler ?
>>> Are they capable of re-ordering the instructions ?
>>> For example inserting other instruction between two loads (on machine
>>> with one load unit) to avoid pipeline stall.
>> 
>> Good assemblers don’t do optimization; that is the job of the compiler (or, in the uncommon case of hand-written assembly language, the programmer).  The MIPS assembler is an aberration, fortunately a rare one.  Note that this “optimization” machinery is turned off by recent compilers when they feed generated code to the assembler, because it gets in the way of the compiler doing a better job.
> 
> AFAIR PS3 assembler was also optimizing (e.g. it could do register allocation and instruction scheduling).

And DEC’s Alpha assembler could also do some of that (since it was in fact hacked into the back end of the compiler).

That doesn’t affect my conclusion.  The normal job (these days) of the assembler is to process compiler output.  For that, the compiler is doing the optimizing and it wants the assembler to keep its hands off.  In the days of GCC 3, the assembler did some of this stuff, and the result was at best suboptimal if not actually problematic.  Now the compiler tells the MIPS assembler to be a good assembler and all is well.

The other (now rare) job of the assembler is to process human-written assembly code.  There too it must stay out of the way, because the only time when hand-written assembly code is justified is when the human needs *complete* control over what happens.  I’ve seen any number of nasty bugs in MIPS hand-written assembly code (like bootstraps or low level diagnostics) cause by people forgetting to say “.set noreorder” and whatever other commands are needed to make the MIPS assembler work like a correct assembler.

So in short, I view all “optimizing assemblers” as design errors.

	paul



More information about the Binutils mailing list