AArch64CollectLOH.cpp contained an algorithm for analysing reaching definitions of physregs globally. To make this available to other targets, it has been factored out as an independent CodeGen class. This was originally suggested by Quentin Colombet.
The algorithm finds defs and users per register (color). It is possible to add any number of regs to be analyzed. The inverse map from user to defs per register is also built. The analyzis of operands is heavily overloadable to suit particular contexts, e.g. treating defs of a particular reg as a use etc.
SystemZElimCompare.cpp was the initial reason for trying this. It however turned out that using this gave only very marginal results. (70 more eliminated compares and 15 more fused compare/branch, where the total for these stats are ~200000). There were about 600 cases with multiple defs (pruned) that might theoretically be handled, but that seems unlikely to be worth the effort.
Since it is marginally better, it would still perhaps be preferred to use this new class, provided that other targets do the same, since that would reduce custom code also in the SystemZ backend (even thought it isn't much).
- The API is just beginning to take form, and is at this point just enough to use it in the SystemZ and AArch64 files. It is hopefully possible to add new data structures / query methods to suit any type of situation.
- The AARch64CollectLOH.cpp file has been rewritten to use this new class instead. That part of the patch is imperfect and should preferably be looked over by a backend maintainer, plus verfied for NFC.