1Date: Fri, 1 Jun 2001 16:38:17 -0500 (CDT)
2From: Chris Lattner <sabre@nondot.org>
3To: Vikram S. Adve <vadve@cs.uiuc.edu>
4Subject: Interesting: GCC passes
5
6
7Take a look at this document (which describes the order of optimizations
8that GCC performs):
9
10http://gcc.gnu.org/onlinedocs/gcc_17.html
11
12The rundown is that after RTL generation, the following happens:
13
141 . [t] jump optimization (jumps to jumps, etc)
152 . [t] Delete unreachable code
163 .     Compute live ranges for CSE
174 . [t] Jump threading (jumps to jumps with identical or inverse conditions)
185 . [t] CSE
196 . *** Conversion to SSA 
207 . [t] SSA Based DCE
218 . *** Conversion to LLVM
229 .     UnSSA
2310.     GCSE
2411.     LICM
2512.     Strength Reduction
2613.     Loop unrolling
2714. [t] CSE
2815. [t] DCE
2916.     Instruction combination, register movement, scheduling... etc.
30
31I've marked optimizations with a [t] to indicate things that I believe to
32be relatively trivial to implement in LLVM itself.  The time consuming
33things to reimplement would be SSA based PRE, Strength reduction & loop
34unrolling... these would be the major things we would miss out on if we
35did LLVM creation from tree code [inlining and other high level
36optimizations are done on the tree representation].
37
38Given the lack of "strong" optimizations that would take a long time to
39reimplement, I am leaning a bit more towards creating LLVM from the tree
40code.  Especially given that SGI has GPL'd their compiler, including many
41SSA based optimizations that could be adapted (besides the fact that their
42code looks MUCH nicer than GCC :)
43
44Even if we choose to do LLVM code emission from RTL, we will almost
45certainly want to move LLVM emission from step 8 down until at least CSE
46has been rerun... which causes me to wonder if the SSA generation code
47will still work (due to global variable dependencies and stuff).  I assume
48that it can be made to work, but might be a little more involved than we
49would like.
50
51I'm continuing to look at the Tree -> RTL code.  It is pretty gross
52because they do some of the translation a statement at a time, and some
53of it a function at a time...  I'm not quite clear why and how the
54distinction is drawn, but it does not appear that there is a wonderful
55place to attach extra info.
56
57Anyways, I'm proceeding with the RTL -> LLVM conversion phase for now.  We
58can talk about this more on Monday.
59
60Wouldn't it be nice if there were a obvious decision to be made?  :)
61
62-Chris
63
64