An issue for the SC: horrible documentation quality of GCC
Richard Kenner
kenner@vlsi1.ultra.nyu.edu
Sat May 10 16:49:00 GMT 2003
just from practice -- looking where did this "pragmatic approach" bring
gcc. Yes, we have might and cool "CSE" pass; but after 2 years working
on gcc, I would not dare to change a single line there because I don't
know what will happen.
That's just lack of familiarity. I fully understand cse.c but am afraid to
change any line of gcse.c!
no -- there are optimizations that are obviously machine-dependent
(like scheduling, register allocation, peephole, combiner and whole
lot of others). Then there are optimizations that are based on some
general machine non-specific idea (like that computing one expression
several times is wrong, or that replacing variable with its constant
value is good -- CSE, GCSE, copy/const propagation, part of the loop
optimizations and some other fall into this cathegory).
I don't understand this distinction at all. The combiner, for example, acts
by always decreasing the number of insns. That's a very machine-independent
criteria and optimization. All of the folding done by it and CSE are
machine-independent.
Replacing a variable with it's constant value may or may not be an
"optimization", but whether it is or not is a machine-dependent choice, so I
don't see why you consider that in the machine-dependent parts.
CSE can be viewed as very machine-dependent because the choice of which
expression is best for a given insn is dependent on lots of machine-specific
parameters.
And even "computing one expression several times is wrong" may not be correct
for simple enough expressions when register pressure is an issue.
So I really don't see *any* optimization that, done properly, is
machine-independent. The key to GCC has been to use machine-specific
information to guide all optimizations.
The sane way how to write a compiler is to run these generic passes
first, then run machine-dependent passes that may eventually fix the
mistakes the previous optimizations have done (due to their generic
ideas being not right in some corner cases). This way we would get
approximately the same results, but in much more transparent way.
No, I disagree. Some machine-dependent optimization might expose more
common expressions or loop invariants.
The issue of what order to run optimizations is very tricky and I don't
think can be answered in that sort of general way.
More information about the Gcc
mailing list