On Thu, 2020-04-23 at 07:07 -0500, Segher Boessenkool wrote: > > > I think at least one step would be uncontroversical(?), namely moving > > the RTL expansion "magic" > > up to a GIMPLE pass. Where the "magic" would be to turn > > GIMPLE stmts not directly expandable via an existing optab into > > GIMPLE that can be trivially expanded. That includes eventually > > combining multiple stmts into more powerful instructions and > > doing the magic we have in, like, expand_binop (widening, etc.). > > Where there's not a 1:1 mapping of a GIMPLE stmt to an optab > > GIMPLE gets direct-internal-fn calls. > > Then RTL expansion would be mostly invoking gen_insn (optab-code). > > Most of expand is *other stuff*. Expand does a *lot* of things that are > actually changing the code. And much of that is not done anywhere else > either yet, so this cannot be fixed by simply deleting the offending code. A lot of what is done by the expansion pass is historical and dates back to when we never optimized more than a statement at a time for trees and the real heavy lifting was all done in RTL.
THe introduction of tree-ssa meant that all the expansion code which wanted to see a "nice" complex statement and generate good RTL code was useless and as a result we saw significant regressions in the end code quality. That in turn brought in TER who's sole purpose was to reconstruct those more complex trees for the purposes of improving initial expansion. I think match.pd has the potential to make TER go away as match.pd is a generic combining framework. WRT extending SSA deeper, I'm all for it and it's always been something I wanted to see happen. I've always believed we could do RTL SSA to the register allocation phase and that doing so would be a positive. If we start at the front of the RTL pipeline and work towards the back we bump into CSE quickly, which would be good. Our CSE is awful across multiple axis. I suspect most RTL passes would be reimplementations rather than bolting SSA on the side and I suspect those reimplementations would be simpler than the existing stuff -- I'm a strong believer there's a lot of dead code in the RTL passes as well. jeff