|Anonymous | Login | Signup for a new account||2018-06-23 12:31 CEST|
|Main | My View | View Issues | Change Log | Roadmap|
|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0007535||OCaml||back end (clambda to assembly)||public||2017-05-18 22:19||2017-09-30 18:09|
|Priority||normal||Severity||feature||Reproducibility||have not tried|
|Target Version||Fixed in Version|
|Summary||0007535: Improve sharing of values|
|Description||Given following snippet of a code:|
type 'a id = Id of 'a
let make (Id x) = Id x
allocation happens every time 'make' called (using flambda-enabled compiler).
Unfortunately it prevents a lot of further optimizations that could happen if it was compiled as simply
let make (Id _ as x) = x
It seems that flambda already capable of eliminating some allocations, i.e.
let make x =
let f (Id x) = Id x in
f @@ f @@ f @@ f @@ f x
allocates only one block.
|Tags||No tags attached.|
In this specific example, you'd be better off adding [@@unboxed] on the type definition (or using the command flag that adds it implicitely).
But it's true that sometimes, the compiler could avoid reallocating things, especially when the workaround is not expressible in the source like:
|  -> assert false
| hd :: tl -> hd, tl
|2017-05-18 22:19||Eugene||New Issue|
|2017-05-19 03:34||sliquister||Note Added: 0017806|
|2017-09-30 18:09||xleroy||Status||new => acknowledged|
|Copyright © 2000 - 2011 MantisBT Group|