Skip to content

better compilation of min and max #4808

@vicuna

Description

@vicuna

Original bug ID: 4808
Reporter: jerhoud
Status: resolved (set by @xavierleroy on 2012-04-08T17:35:02Z)
Resolution: suspended
Priority: normal
Severity: feature
Version: 3.10.2
Category: ~DO NOT USE (was: OCaml general)
Duplicate of: #5541
Monitored by: @ygrek @hcarty

Bug description

Pervasives functions min and max never get inlined because they are polymorphic.

Using min or max on int values implies 2 function calls (one to min or max and an indirect one to caml_lessequal).

A specialized version of min and max for type int gets inlined in ~4 simple assembler instructions.

A nice feature would be that polymorphic functions get inlined using the knowledge of the actual types of the arguments.

If this is too complicated (or not worth the work) perhaps min and max could be special for the compiler (like '<' is)

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