<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="">Hi Quentin,<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Jul 31, 2018, at 12:04 AM, Quentin Colombet <<a href="mailto:quentin.colombet@gmail.com" class="">quentin.colombet@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Hi Amara,</span><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Thanks for sharing the plan going forward.</span><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Inlined a couple of comments.</span><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">2018-07-30 7:01 GMT-07:00 Amara Emerson via llvm-dev <</span><a href="mailto:llvm-dev@lists.llvm.org" style="font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">llvm-dev@lists.llvm.org</a><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">>:</span><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><blockquote type="cite" style="font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">Hi all,<br class=""><br class="">Over the past few months we’ve been doing work on the foundations for the<br class="">next stages of GlobalISel development. In terms of changes from this time<br class="">last year, the IR translator, the legalizer, and instruction selector have<br class="">seen moderate to major changes. The most significant of these was the change<br class="">to the legalizer API, allowing targets to use predicates to express<br class="">legality, which gives more precise control over what forms of instructions<br class="">are legal, and how to legalize them. This was necessary to implement support<br class="">for the new extending loads and truncating stores, but also results in more<br class="">concise and elegant expressions of legality for each target. For example,<br class="">you can now apple a single definition to apply to multiples opcodes (G_ADD,<br class="">G_SUB, G_MUL etc).<br class=""><br class="">The IR translator has been modified to split aggregates rather than handling<br class="">them as one single large scalar. This change fixed some bugs and was<br class="">necessary in order handle big endian code correctly in future.<br class=""><br class="">The tablegen instruction selector also saw significant improvements in<br class="">performance, helping to keep overall compile time regression vs fastisel to<br class="">be <5% geomean on CTMark. There are still a few outliers like sqlite3 which<br class="">has a significant regression compared to FastISel, but most of the other<br class="">benchmarks show little difference or even improvement.<br class=""><br class="">The tablegen importer has had improvements made to it, so that we can import<br class="">more SelectionDAG selection rules. For example, currently on AArch64 we have<br class="">about 40% of the rules being successfully imported.<br class=""><br class="">New additions from last year include the beginnings of a new combiner,<br class="">although there’s still significant work to be done here in terms of the<br class="">final design. The combiner will become a critical part of the pipeline in<br class="">order to begin improving runtime performance.<br class=""><br class="">High levels goals<br class=""><br class="">Going forward, we plan to improve GlobalISel in a number of key areas to<br class="">achieve the following targets:<br class="">* Keeping compile time under control, ideally within 5% of FastISel, and<br class="">when optimizations are enabled to maintain a compile time advantage of<br class="">SelectionDAG.<br class="">* Begin improving runtime performance by adding the most important<br class="">optimizations required to be competitive at -Os. We will be targeting and<br class="">measuring AArch64 for this goal but will endeavor to implement as many<br class="">optimizations as possible in generic code to benefit other targets.<br class="">* Improving overall stability and test coverage. Maintaining a high level<br class="">of code quality and minimizing regressions in correctness and performance<br class="">will be a significant challenge.<br class="">* Ensure that the overall design meets the needs of general targets, not<br class="">being overly tuned to a specific implementation.<br class=""><br class="">Design work planned<br class=""><br class="">These are some design changes coming in the near to medium term future:<br class=""><br class="">* The G_MERGE and G_UNMERGE opcodes will be split into separate opcodes to<br class="">handle different use cases. At the moment the opcode is too powerful,<br class="">resulting in overly complex handling in places like the legalizer. G_MERGE<br class="">will be split so that it only handles merging of scalars into one larger<br class="">scalar. For other cases like merging scalars into a vector we will create a<br class="">new G_BUILD_VECTOR opcode, with a new counterpart opcode for doing the<br class="">opposite. For the current vector + vector case a new G_CONCAT_VECTOR will be<br class="">introduced. With these changes it should simplify implementations for all<br class="">targets.<br class=""><br class="">* Constant representation at the MI level needs some investigation. We<br class="">currently represent constants as generic instructions, with each instance of<br class="">a constant being largely independent of each other, being stored in the<br class="">entry block except for a few places in IR translation where we emit at the<br class="">point of use. As a result we run a localizer pass in an effort to reduce the<br class="">live ranges of the constants (and the consequent spilling), using some<br class="">heuristics to decide where to sink the constant definitions to.<br class=""><br class="">Since we don’t do any real caching of MI constants, multiple G_CONSTANT<br class="">definitions can exist for the same constant. This can also result in a lot<br class="">of redundant constants being created, especially for things like address<br class="">computation. Reducing the number of constants can help reduce compile time<br class="">and memory usage. Given this situation, one possible approach is to encode<br class="">constants into the operands of the users, rather than have dedicated machine<br class="">instructions. At instruction selection time the constant can then be<br class="">materialized into a register or encoded as an immediate. Further<br class="">investigation is needed to find the right way forward here.<br class=""></blockquote><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">The initial design was to not have constant in machine operands. The</span><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">main rational is materializing a constant may be expensive, so we</span><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">better not sprinkle it around.</span><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Now, in practice, this indeed means that we need to keep a table of</span><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">all the constants created so that we don't start to duplicate them,</span><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">which we fail to do. That should be easy to fix that just a map</span><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">virtual register + type to constant that could be kept at the function</span><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">level (or even module level). Better yet, this could be handled by the</span><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">IRBuilder. E.g., when instantiating a IR builder, it could scan the</span><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">function to see which constants are already there and build this</span><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">mapping and then, create only the constants that are missing.</span><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Moreover, another the advantage of this model is that optimizations</span><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">don't have to deal with two variants of the same instruction (ADDr and</span><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">ADDi), same for patterns. Alternatively, if we don't change the</span><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">opcode, but only the MachineOperands, then every optimization has to</span><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">deal with two different kind of opcodes. Which is bad IMHO.</span><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Also, this design was meant to absorb what the constant hoisting pass</span><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">does on the IR, so that we can kill that pass while having a better</span><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">cost model.</span><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Finally, regarding the localizer pass, this was meant as a workaround</span><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">for the fast regalloc problem and should be killed asap. In</span><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">particular, the main motivation was to avoid code size bloat, but</span><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">AFAIR during our last measurements with Ahmed, we only saved a few %</span><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">on a handful of benchmarks, so maybe we can just kill it.</span><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""></div></blockquote>All valid points, however we're now seeing more and more constants created especially as part of address computation, e.g. GEP offsets. Without a solution to the regalloc problem, code size and compile time is taking a hit. IMO a few % is significant enough to warrant considerable effort. For example, a quick constant deduplication experiment I did saved around 1.5% in overall compile time alone.</div><div><br class=""></div><div>If the fast regalloc issue can be fixed without a significant compile time impact then I agree it sounds like the best approach combined with early deduplication. It’s definitely something we’ll look into.<br class=""><blockquote type="cite" class=""><div class=""><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><blockquote type="cite" style="font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br class="">* For optimizations to be supported, the combiner will become a crucial<br class="">part of the GISel pipeline. We have already done some preliminary work in a<br class="">generic combiner, which will be used to eventually support combines of<br class="">extloads/truncstores. We’ve had discussions on and off list about what we<br class="">need from the new combiner. The summary is that we want the combiner to be<br class="">flexible for each target to select from a library of combines, being as<br class="">efficient as possible. The expression of the combines are currently written<br class="">in C++, but one piece of investigation work we might do is to prototype<br class="">using the same tablegen driven instruction selector code to match<br class="">declarative combine patterns written in tablegen. Regardless, we will need<br class="">to support the custom C++ use case.<br class=""><br class="">* CSE throughout the pipeline. From a theoretical perspective, having a<br class="">self contained CSE pass that operates as a single phase in the pipeline is<br class="">attractive for the simplicity and elegance. However, we know empirically<br class="">that this is expensive in compile time. Not only does the CSE pass itself<br class="">take a non-negligible time to run, but having it as a late pass can result<br class="">in the non-CSE’d code from the IRTranslator onwards surviving for a long<br class="">time, taking up time in analysis at each stage of compilation. We believe<br class="">running a light weight CSE early is a win. SelectionDAG currently does CSE<br class="">by default when building the DAG, and this is something we could explore as<br class="">part of a custom IRBuilder.<br class=""></blockquote><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">I have been pushing for having the IRBuilder being smarter. Having</span><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">this doing CSE was something I wanted we try.</span><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""></div></blockquote>Yes IRBuilder is one of the candidates we’ll try for this.<br class=""><blockquote type="cite" class=""><div class=""><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><blockquote type="cite" style="font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br class="">* Known bits computation. Some optimizations require the knowledge of which<br class="">bits in a value are known to be 1 or 0, and do this by using the<br class="">computeKnownBits() capability for SelectionDAG nodes. We will need some way<br class="">of getting the same information. In an ideal scenario the replacement<br class="">infrastructure for this will be more efficient, as this part of the codebase<br class="">seems to be disproportionately responsible for pathological compile time<br class="">regressions.<br class=""><br class="">* Load/store ordering needs some thought, as we currently don’t have a way<br class="">to easily check at the MI level what the ordering requirements are on a set<br class="">of memory operations. SelectionDAG uses the chains to ensure that they’re<br class="">scheduled to respect the orderings. How to achieve the same thing remains an<br class="">open question for GlobalISel.<br class=""></blockquote><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">I don't get this problem.</span><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">GISel has a sequential IR, the order is already modeled here.</span><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Dominance should give us the relative ordering, then if we want more,</span><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">we should do exactly what we do at the IR level (alias analysis, etc.)</span><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""></div></blockquote>Sorry, I didn’t elaborate this properly. The information is there, you’re right about that. The problem is that finding if a load/store A precedes another in a block potentially requires a scan of every instruction since they’re stored as ilists. What chains give as a side effect of the implementation is a way to walk through the dependent memory operations without doing a backwards scan of every instruction. A simple block level cache might work here. As you say if we want more information then something akin to MemorySSA might be useful one day for whole CFG analysis.<br class=""><blockquote type="cite" class=""><div class=""><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Cheers,</span><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">-Quentin</span><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><blockquote type="cite" style="font-family: SFMono-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br class="">* More extensive tests that exercise multiple stages of the pipeline. One<br class="">advantage of using MIR with GISel is that individual passes can be easily<br class="">tested by feeding the exact input expected for a particular pass, and<br class="">checking the immediate output of the pass. However this approach can leave<br class="">holes in the test coverage. To help mitigate this, we will be exploring<br class="">writing/generating whole pipeline tests, tracking some IR through each pass<br class="">and checking how the MIR is mutated. We currently also have a proposed<br class="">change to allow usage of FileCheck as a library, not just as a stand-alone<br class="">tool. This would allow us to use FileCheck style checks and Improve testing<br class="">of currently unused code paths.<br class=""><br class=""><br class="">Roadmap for enabling optimizations<br class=""><br class="">I’ve filed a few PRs that people can follow or comment on to track the<br class="">progress towards enabling the -Os optimization level. The rough outline is:<br class=""><br class="">PR 38365 - [AArch64][GlobalISel] Never fall back on CTMark or benchmarks<br class="">(Darwin)<br class="">PR 38366 - GlobalISel: Lightweight CSE<br class="">PR 32561 - GlobalISel: placement of constants in the entry-block and fast<br class="">regalloc result in lots of reloaded constant<br class="">PR 38367 - GlobalISel: Implement support for obtaining known bits<br class="">information<br class="">PR 38368 - GlobalISel: Investigate an efficient way to ensure load/store<br class="">orderings<br class=""><br class="">These, along with general design and implementation work on the combiner,<br class="">will then lead onto a long road of performance analysis, inevitable bug<br class="">fixing, and implementing more optimizations.<br class=""><br class="">If anyone is interested in discussing in more detail, feel free to reach out<br class="">on the list, or to any of the GlobalISel developers. We’d especially like to<br class="">hear about any issues or concerns about porting targets to GlobalISel.<br class=""><br class="">Thanks,<br class="">Amara<br class=""><br class="">_______________________________________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</blockquote></div></blockquote></div><br class=""></body></html>