Re: Which part of optimization is most important in a compiler?



joggingsong@xxxxxxxxx wrote:
I haven't taken the compiler course at college. Because my job is
to optimize code on DSP, I hope to understand compiler deep and begin
to read a compiler textbook. There are a lot of materials in a book,
but the overview of advanced compiling is not given in the book.

Maybe every part is important for a optimized compiler. I hope to know
which part of a compiler is most important in a compiler. Instruction
scheduling, or register allocation?

"Most important" is an impossible question to answer -- it depends on
which one is being done badly. If the instruction scheduling is done
badly, the compiled program will spend all its time with stalled
pipelines and run slowly, and the best register allocation in the world
won't fix it. If the register allocation is done badly, the compiled
program will spend all its time in memory fetches and stores and run
slowly, and the best instruction scheduling in the world won't fix it.

It also depends heavily on the processor architecture and the program.
On a Cell SPE, instruction ordering can make an order-of-magnitude
difference in execution time, but with 128 registers, allocating the
registers in an optimum way is often not especially critical. On a
processor that does instruction-reordering in hardware but has a
half-dozen registers, however, the register allocation is critical and
the instruction ordering much less so. I don't know where your DSP
would fit in this spectrum.

With that said, a program with poor instruction scheduling will still
run, whereas the registers have to be allocated _somehow_ in order to
get a running program, so you might as well learn about register
allocation first.

Also, if you have any experience with writing assembly-code programs for
your DSP, that should give you some insight into what's most important
to get things to run fast on your processor. (If you don't have
experience with that, it's probably useful to get some -- it's hard to
write a program to produce something that you don't know how to produce
yourself!)

- Brooks


--
The "bmoses-nospam" address is valid; no unmunging needed.
.



Relevant Pages

  • Re: Bad performance on alpha? (make buildworld)
    ... It's been a few years since I'd written a compiler, ... it is 4-way superscalar but the different execution ... instruction decode stages rather than just the integer pipeline), ... > architecture and relying on the L1 cache to handle the register spills ...
    (freebsd-performance)
  • Re: Register keyword and "as if" rule...
    ... Register allocation is provably NP-hard, and is solved by very compute ... out-think the compiler when it comes to register allocation. ... It may be better for that application to allocate 50% of the registers to optimizing 10 lines of code in the critical path. ...
    (comp.lang.c)
  • Re: Variadic functions calling variadic functions with the argument list, HLL bit shifts on LE proce
    ... There's no such thing as a "LE register" on most popular CPU ... shift is done on the value. ... >but one would hope that the shr for shift right instruction would ... The compiler needs to use assembler instructions. ...
    (comp.lang.c)
  • Re: instruction bundling (scheduling?)
    ... produced assembly code with basic-block register allocation (using ... All list scheduling I've seen deal with latency. ... consider an instruction that could still be in the ... if on the other hand, register allocation is done after scheduling, ...
    (comp.compilers)
  • Re: Bad performance on alpha? (make buildworld)
    ... >a relatively simple but orthagonal instruction set, ... >the compiler to generate and optimize code. ... Alpha pipelines are only short in a relative sense - the EV5 pipeline ... architecture and relying on the L1 cache to handle the register spills ...
    (freebsd-performance)