Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007535OCamlback end (clambda to assembly)public2017-05-18 22:192017-05-19 03:34
ReporterEugene 
Assigned To 
PrioritynormalSeverityfeatureReproducibilityhave not tried
StatusnewResolutionopen 
PlatformOSOS Version
Product Version4.04.1 
Target VersionFixed in Version 
Summary0007535: Improve sharing of values
DescriptionGiven 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.
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0017806)
sliquister (reporter)
2017-05-19 03:34

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:

function
| [] -> assert false
| hd :: tl -> hd, tl

- Issue History
Date Modified Username Field Change
2017-05-18 22:19 Eugene New Issue
2017-05-19 03:34 sliquister Note Added: 0017806


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker