Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Does Caml have slow arithmetics ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-07-07 (15:08)
From: Xavier Leroy <Xavier.Leroy@i...>
Subject: Re: [Caml-list] Does Caml have slow arithmetics ?
> Do developers plan to add new kinds of optimization in a near future?
> Trivial example:
> let f a b =
>     let a, b = a, b in
>         a + b
> let g a b =
>     a + b

The main purpose of OCaml's compiler optimizations is to avoid
introducing inefficiencies while compiling.  In other terms, the main
objective is to generate good machine code from good source code.
In this respect, optimizations of redundant tagging operations is
crucial, since this aspect of execution is not apparent in the source
code.  Other examples include register allocation and instruction
selection, which are not under the programmer's control

On the other hand, reducing inefficiencies already present in the
source code isn't a priority.  In your "f" function, you asked for the
construction of a pair, and you get that pair construction in
ocamlopt's output.  If you didn't want the pair to be constructed, why
did you write "f" this way?

- Xavier Leroy

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: