Re: code optimization in embedded systems



Jyrki Saarinen wrote:
Ken Asbury <avoidingspam2001@xxxxxxxxx> wrote:

We have found this to be largely false. Dropping into assembly
interrupts C optimization, and can thereby eliminate any savings.
Not to sound argumentative, but my experience (and a very good living
over the last 30+ years) has repeatedly demonstrated that, in an
embedded environment, someone familiar with both disciplines can
routinely achieve an order of magnitude improvements in speed of
selected functions. The trick is to be able to determine which
functions to rewrite in assembler.

This must apply only for architectures, for which it is difficult for the compiler to emit good code. If you get order of magnitude improvement in performance when hand-coding a function in assembly, the compiler must be quite bad. The reverse statement might apply on architectures with deep pipelines, several functional units and a large register set.

For the last sentence for yours: one should profile before doing anything else..


Remember that in binary, an order of magnitude is only a factor of two :-)

.



Relevant Pages

  • Re: Just what makes an architecture "C Friendly"?
    ... are the other merits/demerits of the various architectures? ... checking what the compiler had produced, ... pleasant surprise - the generated assembler was alien;). ... like push/pop parameter stacks even when no parameters were used, ...
    (comp.arch.embedded)
  • Re: code optimization in embedded systems
    ... functions to rewrite in assembler. ... This must apply only for architectures, for which it is difficult for the ... compiler to emit good code. ...
    (comp.arch.embedded)
  • Re: code optimization in embedded systems
    ... functions to rewrite in assembler. ... This must apply only for architectures, for which it is difficult for the ... compiler to emit good code. ...
    (comp.arch.embedded)
  • Re: i++ and ++i
    ... You would need to look at the assembler ... a single increment instruction for a given usage to a call to multiple ... Examining the assembly output of a compiler may give you ... early versions of my compiler, for certain register limited architectures, ...
    (comp.lang.c)
  • Re: What micros do you actually hate to work with?
    ... with less than tiny asm ... hassle to work with 32 bit longs in assembler for an 8 bit uP, ... Microchip's C compiler tools and their assembly under MPLAB. ... is that other programmers for C are easier to find. ...
    (comp.arch.embedded)