From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=HTML_MESSAGE autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 7AB03BBAF for ; Tue, 10 Jun 2008 21:01:13 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Aj8BAA9sTkhC+Vytd2dsb2JhbACCPjWPHQEMAwQECREDmViFRg X-IronPort-AV: E=Sophos;i="4.27,618,1204498800"; d="scan'208";a="13791545" Received: from ug-out-1314.google.com ([66.249.92.173]) by mail3-smtp-sop.national.inria.fr with ESMTP; 10 Jun 2008 21:01:13 +0200 Received: by ug-out-1314.google.com with SMTP id m4so138665uge.18 for ; Tue, 10 Jun 2008 12:01:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type; bh=9diwybDO5asvRWAcn55un86iuSkTknhNzAScmq3AIEg=; b=IwT8RIfqCm3nBGP+xH4OF3AEstj2Ys4lcAJCH6acKrI99b7os+r9PliYo4QvCDva2m Ka2ZtGjmn8mv2xd3DlvbagUzjAblbyerh9FIUnxfT1ky2bNg8ceAHFApzl9HxviSBoQ3 llhh4iVqMFIkFvfHu0cJtlmijWM4ZgAQuGtig= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=XdODITA+NYKXCZDAfPELCQ4Gof4GRE5geqSFT4uK1PtmS3g7G09xE0jPGf6Mc4oG76 DXAoTcvoCenZAeGXpVlWWg9CU2wlppA5V4+zxHVPxLsXTF2z+WazXcyBZa8pIJh2IBK0 x6f5WOh2Q+fYY2uxp1UjEyhd6z/OAFKSPprY0= Received: by 10.210.79.14 with SMTP id c14mr4364545ebb.181.1213124472418; Tue, 10 Jun 2008 12:01:12 -0700 (PDT) Received: by 10.210.39.11 with HTTP; Tue, 10 Jun 2008 12:01:12 -0700 (PDT) Message-ID: <676aba050806101201x526f03b1lf1fdbed665ee2e3f@mail.gmail.com> Date: Tue, 10 Jun 2008 21:01:12 +0200 From: "Charles Hymans" To: caml-list@yquem.inria.fr Subject: optimization of sequence of List.map and inlining MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_9611_27895846.1213124472404" X-Spam: no; 0.00; inlining:01 compiler:01 compiler:01 optimization:03 element:03 element:03 let:03 let:03 applied:05 applied:05 fun:08 fun:08 passes:10 passes:10 runs:11 ------=_Part_9611_27895846.1213124472404 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Let's say, I have the following code: let f l = List.map succ l .... let l = f l in let l = List.map succ l in do_something_with l Is there a way to tell the compiler to optimize it so that it runs as fast as this code: let l = List.map (fun x -> succ (succ x)) l in l In the first case, there are two passes where succ is applied to each elements of the list. In the second case, there is only one pass that applies succ twice to each element of the list. Thank you, ------=_Part_9611_27895846.1213124472404 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline
Let's say, I have the following code:
 
  let f l = List.map succ l
 
  ....
 
  let l = f l in
  let l = List.map succ l in
    do_something_with l
 
 
Is there a way to tell the compiler to optimize it so that it runs as fast as this code:
  let l = List.map (fun x -> succ (succ x)) l in
    l
In the first case, there are two passes where succ is applied to each elements of the list.
In the second case, there is only one pass that applies succ twice to each element of the list.
 
Thank you,
------=_Part_9611_27895846.1213124472404--