<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica;" class="">Hi all,</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica;" class=""><span style="font-kerning: none" class="">Over the past few months we’ve been doing work on the foundations for the next stages of GlobalISel development. In terms of changes from this time last year, the IR translator, the legalizer, and instruction selector have seen moderate to major changes. The most significant of these was the change to the legalizer API, allowing targets to use predicates to express legality, which gives more precise control over what forms of instructions are legal, and how to legalize them. This was necessary to implement support for the new extending loads and truncating stores, but also results in more concise and elegant expressions of legality for each target. For example, you can now apple a single definition to apply to multiples opcodes (G_ADD, G_SUB, G_MUL etc).</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica; min-height: 14px;" class=""><span style="font-kerning: none" class=""></span><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica;" class=""><span style="font-kerning: none" class="">The IR translator has been modified to split aggregates rather than handling them as one single large scalar. This change fixed some bugs and was necessary in order handle big endian code correctly in future.</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica; min-height: 14px;" class=""><span style="font-kerning: none" class=""></span><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica;" class=""><span style="font-kerning: none" class="">The tablegen instruction selector also saw significant improvements in performance, helping to keep overall compile time regression vs fastisel to be <5% geomean on CTMark. There are still a few outliers like sqlite3 which has a significant regression compared to FastISel, but most of the other benchmarks show little difference or even improvement.</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica; min-height: 14px;" class=""><span style="font-kerning: none" class=""></span><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica;" class=""><span style="font-kerning: none" class="">The tablegen importer has had improvements made to it, so that we can import more SelectionDAG selection rules. For example, currently on AArch64 we have about 40% of the rules being successfully imported.</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica; min-height: 14px;" class=""><span style="font-kerning: none" class=""></span><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica;" class=""><span style="font-kerning: none" class="">New additions from last year include the beginnings of a new combiner, although there’s still significant work to be done here in terms of the final design. The combiner will become a critical part of the pipeline in order to begin improving runtime performance.</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica; min-height: 14px;" class=""><span style="font-kerning: none" class=""></span><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica;" class=""><span style="font-kerning: none" class=""><b class="">High levels goals</b></span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica; min-height: 14px;" class=""><span style="font-kerning: none" class=""></span><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica;" class=""><span style="font-kerning: none" class="">Going forward, we plan to improve GlobalISel in a number of key areas to achieve the following targets:</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica;" class=""><span style="font-kerning: none" class=""> * Keeping compile time under control, ideally within 5% of FastISel, and when optimizations are enabled to maintain a compile time advantage of SelectionDAG.</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica;" class=""><span style="font-kerning: none" class=""> * Begin improving runtime performance by adding the most important optimizations required to be competitive at -Os. We will be targeting and measuring AArch64 for this goal but will endeavor to implement as many optimizations as possible in generic code to benefit other targets.</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica;" class=""><span style="font-kerning: none" class=""> * Improving overall stability and test coverage. Maintaining a high level of code quality and minimizing regressions in correctness and performance will be a significant challenge.</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica;" class=""><span style="font-kerning: none" class=""> * Ensure that the overall design meets the needs of general targets, not being overly tuned to a specific implementation.</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica; min-height: 14px;" class=""><span style="font-kerning: none" class=""></span><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica;" class=""><span style="font-kerning: none" class=""><b class="">Design work planned</b></span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica; min-height: 14px;" class=""><span style="font-kerning: none" class=""></span><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica;" class=""><span style="font-kerning: none" class="">These are some design changes coming in the near to medium term future:</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica; min-height: 14px;" class=""><span style="font-kerning: none" class=""></span><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica;" class=""><span style="font-kerning: none" class=""> * The G_MERGE and G_UNMERGE opcodes will be split into separate opcodes to handle different use cases. At the moment the opcode is too powerful, resulting in overly complex handling in places like the legalizer. G_MERGE will be split so that it only handles merging of scalars into one larger scalar. For other cases like merging scalars into a vector we will create a new G_BUILD_VECTOR opcode, with a new counterpart opcode for doing the opposite. For the current vector + vector case a new G_CONCAT_VECTOR will be introduced. With these changes it should simplify implementations for all targets.</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica; min-height: 14px;" class=""><span style="font-kerning: none" class=""></span><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica;" class=""><span style="font-kerning: none" class=""> * Constant representation at the MI level needs some investigation. We currently represent constants as generic instructions, with each instance of a constant being largely independent of each other, being stored in the entry block except for a few places in IR translation where we emit at the point of use. As a result we run a localizer pass in an effort to reduce the live ranges of the constants (and the consequent spilling), using some heuristics to decide where to sink the constant definitions to.</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica; min-height: 14px;" class=""><span style="font-kerning: none" class=""></span><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica;" class=""><span style="font-kerning: none" class="">Since we don’t do any real caching of MI constants, multiple G_CONSTANT definitions can exist for the same constant. This can also result in a lot of redundant constants being created, especially for things like address computation. Reducing the number of constants can help reduce compile time and memory usage. Given this situation, one possible approach is to encode constants into the operands of the users, rather than have dedicated machine instructions. At instruction selection time the constant can then be materialized into a register or encoded as an immediate. Further investigation is needed to find the right way forward here.</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica; min-height: 14px;" class=""><span style="font-kerning: none" class=""></span><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica;" class=""><span style="font-kerning: none" class=""> * For optimizations to be supported, the combiner will become a crucial part of the GISel pipeline. We have already done some preliminary work in a generic combiner, which will be used to eventually support combines of extloads/truncstores. We’ve had discussions on and off list about what we need from the new combiner. The summary is that we want the combiner to be flexible for each target to select from a library of combines, being as efficient as possible. The expression of the combines are currently written in C++, but one piece of investigation work we might do is to prototype using the same tablegen driven instruction selector code to match declarative combine patterns written in tablegen. Regardless, we will need to support the custom C++ use case.</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica; min-height: 14px;" class=""><span style="font-kerning: none" class=""></span><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica;" class=""><span style="font-kerning: none" class=""> * CSE throughout the pipeline. From a theoretical perspective, having a self contained CSE pass that operates as a single phase in the pipeline is attractive for the simplicity and elegance. However, we know empirically that this is expensive in compile time. Not only does the CSE pass itself take a non-negligible time to run, but having it as a late pass can result in the non-CSE’d code from the IRTranslator onwards surviving for a long time, taking up time in analysis at each stage of compilation. We believe running a light weight CSE early is a win. SelectionDAG currently does CSE by default when building the DAG, and this is something we could explore as part of a custom IRBuilder.</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica; min-height: 14px;" class=""><span style="font-kerning: none" class=""></span><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica;" class=""><span style="font-kerning: none" class=""> * Known bits computation. Some optimizations require the knowledge of which bits in a value are known to be 1 or 0, and do this by using the computeKnownBits() capability for SelectionDAG nodes. We will need some way of getting the same information. In an ideal scenario the replacement infrastructure for this will be more efficient, as this part of the codebase seems to be disproportionately responsible for pathological compile time regressions.</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica; min-height: 14px;" class=""><span style="font-kerning: none" class=""></span><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica;" class=""><span style="font-kerning: none" class=""> * Load/store ordering needs some thought, as we currently don’t have a way to easily check at the MI level what the ordering requirements are on a set of memory operations. SelectionDAG uses the chains to ensure that they’re scheduled to respect the orderings. How to achieve the same thing remains an open question for GlobalISel.</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica; min-height: 14px;" class=""><span style="font-kerning: none" class=""></span><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica;" class=""><span style="font-kerning: none" class=""> * More extensive tests that exercise multiple stages of the pipeline. One advantage of using MIR with GISel is that individual passes can be easily tested by feeding the exact input expected for a particular pass, and checking the immediate output of the pass. However this approach can leave holes in the test coverage. To help mitigate this, we will be exploring writing/generating whole pipeline tests, tracking some IR through each pass and checking how the MIR is mutated. We currently also have a proposed change to allow usage of FileCheck as a library, not just as a stand-alone tool. This would allow us to use FileCheck style checks and Improve testing of currently unused code paths.</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica; min-height: 14px;" class=""><br class=""><span style="font-kerning: none" class=""></span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica;" class=""><span style="font-kerning: none" class=""><b class="">Roadmap for enabling optimizations</b></span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica; min-height: 14px;" class=""><span style="font-kerning: none" class=""><b class=""></b></span><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica; min-height: 14px;" class="">I’ve filed a few PRs that people can follow or comment on to track the progress towards enabling the -Os optimization level. The rough outline is:</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Helvetica" class="">PR 38365 - [AArch64][GlobalISel] Never fall back on CTMark or benchmarks (Darwin)</font></div><div style="margin: 0px; font-stretch: normal; line-height: normal; min-height: 14px;" class=""><font face="Helvetica" class=""><span style="font-kerning: none" class=""></span>PR 38366 - GlobalISel: Lightweight CSE</font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Helvetica" class="">PR 32561 - GlobalISel: placement of constants in the entry-block and fast regalloc result in lots of reloaded constant</font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Helvetica" class="">PR 38367 - GlobalISel: Implement support for obtaining known bits information</font></div><div style="margin: 0px; font-stretch: normal; line-height: normal; min-height: 14px;" class=""><font face="Helvetica" class="">PR 38368 - GlobalISel: Investigate an efficient way to ensure load/store orderings<span style="font-kerning: none" class=""></span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica;" class=""><span style="font-kerning: none" class=""><br class=""></span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica;" class=""><span style="font-kerning: none" class="">These, along with general design and implementation work on the combiner, will then lead onto </span>a long road of performance analysis, inevitable bug fixing, and implementing more optimizations.</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica;" class="">If anyone is interested in discussing in more detail, feel free to reach out on the list, or to any of the GlobalISel developers. We’d especially like to hear about any issues or concerns about porting targets to GlobalISel.</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica;" class="">Thanks,</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Helvetica;" class="">Amara</div></body></html>