Re: Optimizing in assembly language

"Scottie" <me@nospam.net>
10 Mar 2001 16:01:13 -0500

          From comp.compilers

Related articles
[3 earlier articles]
Re: Optimizing in assembly language ts3@ukc.ac.uk (T.Shackell) (2001-03-08)
Re: Optimizing in assembly language jguthrie@brokersys.com (Jonathan Guthrie) (2001-03-08)
Re: Optimizing in assembly language l-desnogues@ti.com (Laurent Desnogues) (2001-03-08)
Re: Optimizing in assembly language ceco@jupiter.com (Tzvetan Mikov) (2001-03-08)
Re: Optimizing in assembly language adrian@sartre.cs.rhbnc.ac.uk (A Johnstone) (2001-03-08)
Re: Optimizing in assembly language rhyde@transdimension.com (Randall Hyde) (2001-03-10)
Re: Optimizing in assembly language me@nospam.net (Scottie) (2001-03-10)
Re: Optimizing in assembly language thp@hill.cs.ucr.edu (Tom Payne) (2001-03-12)
Re: Optimizing in assembly language rhyde@transdimension.com (Randall Hyde) (2001-03-14)
Re: Optimizing in assembly language bonzini@gnu.org (2001-03-22)
Re: Optimizing in assembly language thp@hill.cs.ucr.edu (Tom Payne) (2001-03-22)
Re: Optimizing in assembly language Eric.Boon@ICT.nl (Eric Boon) (2001-03-22)
Re: Optimizing in assembly language uabbwat@uab.ericsson.se (Barry Watson) (2001-03-26)
[4 later articles]
| List of all articles for this month |
From: "Scottie" <me@nospam.net>
Newsgroups: comp.compilers
Date: 10 Mar 2001 16:01:13 -0500
Organization: Posted via Supernews, http://www.supernews.com
References: 01-03-006
Keywords: assembler, optimize
Posted-Date: 10 Mar 2001 16:01:13 EST

> So here's my question: why can't we write an "optimizing assembler"
> that lets the programmer specify machine sequences and the assembler
> does the same kinds of "book keeping" that a HLL compiler would do.


IIRC DEC/Mips used at least a bit of this approach. There were some
problems, the most obvious of which were related to use of memory as
semaphores. Code motion to improve memory bandwith removed full
protection of critical sections.
        ...
        while (lock != 0)
                ...
                ;
        lock = 1
        ...update data with mutiple instruction...
        lock = 0
        ...
Dead store elimination, if implemented, can remove locks on
resources above entirely, leaving code like:
        ...
        while (lock != 0)
                ...
                ;
        ...update data with multiple instruction...
        lock = 0
        ...
or even (on discovering the protect loop always exits with lock==0):
        ...
        while (lock != 0)
                ...
                ;
        update data with more than one indivisible instruction
        ...


A "clever" assembler may notice the "lock=1" code is useless because
lock is not examined anywhere in the update, so it may simply
eliminate the lock = 1 altogether. Often this is right, but if we are
concerned with multiple threads viewing the data, the optimization is
wrong. It is tough to determine which bits of assembly are
intentional and which are artifact, and I wouldn't trust an assembler
to do it myself.


Scott David Daniels


Post a followup to this message

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