Open toelli-msft opened 3 years ago
I recommend waiting for https://github.com/microsoft/knossos-ksc/issues/531 to be resolved before implementing this strategy though. It may not be needed at all.
Oh, and in Cgen we can also flatten nested tuple types as function arguments, if we think that would help.
Cgen sometimes generates code like the below
We would expect a good compiler to be able to optimise away such redundancy. However, I believe that a C++ compiler cannot because of technical reasons to do with
std::tuple
's historical properties.See also https://github.com/microsoft/knossos-ksc/issues/528 and https://github.com/microsoft/knossos-ksc/issues/531.
Part of the cause is the way that we unpack tuple arguments in Cgen. Here is a synthesis of ideas from @dcrc2 and @simonpj to avoid the problem.
TupPat
not aVarPat
params_withPackedParamsPat
on each Def.TupPat
not before (or also before, but that's probably redundant). Running optimization after means thatoptLets
has an opportunity to remove this redundancy.