Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: David Monniaux <David.Monniaux@ens-lyon.fr>
To: Jean-Christophe Filliatre <Jean-Christophe.Filliatre@ens-lyon.fr>
Cc: caml-list@inria.fr
Subject: Re: compilation
Date: Tue, 18 Feb 1997 16:26:24 +0100 (MET)	[thread overview]
Message-ID: <Pine.GSO.3.95.970218161852.20320H-100000@bellecour> (raw)
In-Reply-To: <199702131524.QAA03489@anjou.ens-lyon.fr>

[ENGLISH FURTHER IN THE TEXT]

On Thu, 13 Feb 1997, Jean-Christophe Filliatre wrote:

> 1. J'aimerai savoir si :
> 
> 	let b = true
> 	let f = if b then f1 else f2
> 
>    est compilé en f1, c'est-à-dire si la branche d'un "if" est
>    directement sélectionnée lorsque le booléen est "true" ou "false"
>    (sans l'évaluer, bien sûr ; simplement directement égal à "true" ou
>    "false" au moment de la compilation)
>    La raison de ma question est que cela permettrait d'avoir des options
>    de compilation directement en Caml sans perdre d'efficacité.

A ma connaissance, le compilateur ne fait pas de réductions même
triviales... Par exemple
let f=5;;
let g () = 3 * f;;
compile g vers une fonction qui est sémantiquement une constante, mais qui
en pratique prend f (lié =3), le multiplie par 3...

Un bon compilateur C, par contre, simplifierait les expressions...
Cela dit, les systèmes d'analyse de flot et d'optimizations des
compilateurs C réellement utilisés sont énormes...

> =english=====================================================================
> 
> 1. I would like to know if
> 
> 	let b = true
> 	let f = if b then f1 else f2
> 
> is compiled as f1, that is if the branch of an "if" expression is
> directly selected when the boolean expression is "true" or "false"
> (without performing any computation on it, of course; just directly
> equal to the constructor "true" or "false").
> The reason of this question is that it would allow compile options in
> Caml without any loss of efficiency.

To my knowledge, the Ocaml compiler doesn't perform any kind of reduction,
even trivial. For instance,

let f=3;;
let g () = f*4;;
compiles g to a function that is semantically a constant, but that in
effect takes f (lié =3) and multiplies it by 4.

A good C compiler, nevertheless, would simplify those expressions... But
the flow analysis and optimization part of a "real" C compiler is huge...

"Si l'informatique marchait, cela se saurait."
http://www.ens-lyon.fr/~dmonniau





  reply	other threads:[~1997-02-18 15:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-02-13 15:24 compilation Jean-Christophe Filliatre
1997-02-18 15:26 ` David Monniaux [this message]
1997-02-18 16:53 ` compilation Xavier Leroy
1997-02-19  8:12 compilation Franck Cassez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.GSO.3.95.970218161852.20320H-100000@bellecour \
    --to=david.monniaux@ens-lyon.fr \
    --cc=Jean-Christophe.Filliatre@ens-lyon.fr \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox