I’m sure this has been asked many times, but is there current work on decreasing the time taken by the DAG-based instruction selector, or the other phases of llc? I am just beginning to dive into LLVM, and I am interested in compile-time reductions that do not reduce code quality dramatically. For example, simply switching on “-fast-isel” (roughly 17% drop in code quality for some of my benchmarks) or “-regalloc=local/fast” (roughly 2x slower for some of my benchmarks) is, unfortunately, not an acceptable option.
I noticed that a semi-recent commit added the “STATISTIC(NumDAGIselRetries,“Number of times dag isel has to try another path”);” as well as a sorting change in DAGISelEmitter.cpp. This suggests to me that there is work being done. Are there other similar efforts, but perhaps aiming for bigger gains, that I should be aware of? From the other end, are there efforts to make the fast-path produce better quality code?
Some small things I’ve noticed:
- LegalizeVectors might not make a single change over an entire input bc file, yet it can take about 6% of the ISel time. Identifying that this can be skipped ahead of time may help?
- We can take the Changed flag returned by LegalizeVectors, and pass it on to Legalize so that it can decide not to AssignTopologicalOrder again, since it was already done in the LegalizeVectors pass. However, this is a negligible reduction: 0.2 seconds shaved off a 30+ second compile =).
- BuildSchedGraph() can take around 30% of the X% of time taken by Instruction Scheduling. How different is the scheduler graph from the selection graph?
- Just as a random guess that this would not affect code quality terribly, I tried dynamically switching on -fast-isel for basic blocks of size one. This can cover about 10% of the basic blocks. The code-quality drop on a few benchmarks is neglible, but for spec’s 483.xalancbmk it is quite dramatic.
Also, any pointers to documentation, or description of the algorithm used by the Select() → SelectCode() → SelectCodeCommon() pass would be very helpful.
Sorry for the long email, and many thanks in advance!
- Jan Voung