|Anonymous | Login | Signup for a new account||2017-07-23 15:00 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-05-19 03:34|
|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|
|Copyright © 2000 - 2011 MantisBT Group|