-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Improve sharing of values #7535
Copy link
Copy link
Closed
Description
Original bug ID: 7535
Reporter: Eugene
Status: acknowledged (set by @xavierleroy on 2017-09-30T16:09:30Z)
Resolution: open
Priority: normal
Severity: feature
Version: 4.04.1
Category: back end (clambda to assembly)
Bug 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.
Reactions are currently unavailable