Skip to content

Improve sharing of values #7535

@vicuna

Description

@vicuna

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions