Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
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 caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners