OCamlPro / flambda-task-force

13 stars 1 forks source link

Unbox floats used in inlined calls #158

Open bluddy opened 8 years ago

bluddy commented 8 years ago

In the following example, x is not unboxed:

let _ =
  let f = 100. in
  let [@inline always] rec loop x  =
    if x <= 0. then 0.
    else loop (x -. 5.)
  in
  loop f
chambart commented 8 years ago

Something enabling that (not only when inlined in fact) has been attempted before, see https://github.com/chambart/ocaml/tree/float_args This will definitely be done at some point, but needs some big changes in the backend first: https://github.com/OCamlPro/flambda-task-force/issues/153

alainfrisch commented 8 years ago

There are really two ways to attack the problem: either support unboxed calling conventions in general, or optimize the recursive loop into a function-local loop (perhaps using "extended local exceptions") and then rely on the current unboxing strategy (in cmmgen). The latter is more restricted in scope but also simpler to achieve and it could give better performance (in addition to avoiding unboxing, it could benefit from better register allocation).

bluddy commented 8 years ago

Sorry for double-posting this issue. It's also available on mantis here