Dumb question because you are effectively suggesting an alternate calling convention in addition to the existing one: wouldn't it make more sense to switch to a completely different convention? Like: we pass fp values always in fp registers so far available? Sure, there are cases leading to double allocations of the same value then. But getting this under control is some kind of CSE problem, and something that flambda can really deal with. I mean the current calling conventions only exist because of outdated CPU architectures (x87). Maybe it is time to rethink this. Gerd Am Mittwoch, den 21.12.2016, 17:06 +0100 schrieb Alain Frisch: > On 21/12/2016 15:45, Yotam Barnoy wrote: > > > > I think it's not worth the effort. You need to examine all the code > > dealing with a parameter (ie. its flow) to see if any generic > > function > > is called on that parameter. > This would be treated a bit like the stubs for optional arguments > with a  > default value.  Any function taking float arguments or returning a > float  > would be compiled to a specialized version with an unboxed calling  > convention plus a stub which implements the generic calling > convention  > and delegate the call to the specialized version (or copy its body if > it  > is small enough).  On call site, when the called function is known, > one  > calls the specialized version instead.  This is a systematic, local  > compilation scheme, similar to other optimizations made in  > closure/cmmgen; it does not require a more global analysis nor a  > radically different representation of the code. > > About the "it's not worth the effort": the effort has largely been > done,  > since the ticket came with a working patch (some more effort would > be  > needed to bring it up to date, though).  In my opinion, this seems > like  > a rather low-hanging fruit with very immediate and significant > gains.  > I'd rather have this soon than wait for flambda to become stable and  > usable on large projects. > > > > -- Alain > -- ------------------------------------------------------------ Gerd Stolpmann, Darmstadt, Germany gerd@gerd-stolpmann.de My OCaml site: http://www.camlcity.org Contact details: http://www.camlcity.org/contact.html Company homepage: http://www.gerd-stolpmann.de ------------------------------------------------------------