From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 31073BC57 for ; Wed, 15 Dec 2010 11:29:16 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AskAAAAnCE3RVdYtk2dsb2JhbACVeI4kCBYBAgkJCgkRBCCnOIwIAQWOFgEEhUo X-IronPort-AV: E=Sophos;i="4.59,347,1288566000"; d="scan'208";a="92414992" Received: from mail-bw0-f45.google.com ([209.85.214.45]) by mail1-smtp-roc.national.inria.fr with ESMTP; 15 Dec 2010 11:29:15 +0100 Received: by bwz16 with SMTP id 16so2039867bwz.18 for ; Wed, 15 Dec 2010 02:29:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:content-type:mime-version :subject:from:in-reply-to:date:content-transfer-encoding:message-id :references:to:x-mailer; bh=sI1ssySuJ5IWulQiEjTvY8zxhtujGF9ediafUt3d97M=; b=OxWAmhxvBBPAmKxCPCBhoZ2XkRM0bCgfKjfoux/l2yzbvXIBus9LKwk7sMCwQiRDWj kQ4ohD97Naso3J6X4zKCj+Da1LpN0STx8izLVbvGXoOWBLSM6abALRkxspzFq3ZpbkgX /2/fbY5yhjc8IAmQExaEZR4p6CgWm8p2VVlxY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=content-type:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to:x-mailer; b=QuSTrctK5sCf5su22VglHGKoM4hcUYKg+i6DUkK9g8mZ3CToY/xt1L+V9JrbA4K9SM qu7ujW+uqHVkrD0YcTq5jP6Bp23A8n3Lj1+PlmKQJ3S+PhMDJYlX1RypIqLk5Tjumre9 UNKIf5uV7WxKe37RI2W2b9zhptnUVgJP1LAig= Received: by 10.204.63.2 with SMTP id z2mr6631054bkh.66.1292408953933; Wed, 15 Dec 2010 02:29:13 -0800 (PST) Received: from bespin.informatik.uni-siegen.de (bespin.informatik.uni-siegen.de [141.99.131.92]) by mx.google.com with ESMTPS id a27sm396195bka.10.2010.12.15.02.29.11 (version=SSLv3 cipher=RC4-MD5); Wed, 15 Dec 2010 02:29:12 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Apple Message framework v1081) Subject: Re: Value types (Was: [Caml-list] ocamlopt LLVM support) From: Benedikt Meurer In-Reply-To: <4D05DCB6.2060100@frisch.fr> Date: Wed, 15 Dec 2010 11:29:10 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <85AB623B-0278-41F0-9C70-8E8814C0A16F@googlemail.com> References: <036001cb9a0c$725acef0$57106cd0$@com> <20101212175524.73a8e285@deb0> <9264BEE6-DBAE-4523-93AC-4560615D2AC5@googlemail.com> <4D05DCB6.2060100@frisch.fr> To: caml-list@yquem.inria.fr X-Mailer: Apple Mail (2.1081) X-Spam: no; 0.00; ocamlopt:01 frisch:01 compiler:01 conceptually:01 speedups:01 viewcvs:01 ocaml:01 bytecomp:01 wrote:01 wrote:01 heap:01 caml-list:01 alain:01 alain:01 diff:02 On Dec 13, 2010, at 09:43 , Alain Frisch wrote: > On 12/12/2010 08:09 PM, Benedikt Meurer wrote: >> The boxing involved is relevant, but boxing in general is not the >> issue. In this special case, the "let nlen, n =3D if..." code = requires >> heap allocation, because of the way the pattern is compiled. This = could >> be fixed by moving the condition out of the code and using two if's = to >> select n/nlen separately (doesn't speed up that much). Fixing the >> pattern compiler to handle these cases might be interesting for = general >> benefit. >=20 > Instead of duplicating the conditional, you could also push the = assignments to bound variables down the expression. For instance: >=20 > let (x, y) =3D if b then (u, v) else (v, u) in ... >=20 > can be replaced, conceptually, by: >=20 > let x =3D in > let y =3D in > if b then (x <- u; y <- v) else (x <- v; y <- u); > ... >=20 > and similarly when the bound expression is a pattern matching. >=20 >=20 > I've played with this a few months ago and could observe important = speedups (27%, 20%) on two micro-benchmarks. >=20 > The diff is really small: >=20 > = http://caml.inria.fr/cgi-bin/viewcvs.cgi/ocaml/branches/inplace_let/byteco= mp/matching.ml?rev=3D10475&sortby=3Ddate&r2=3D10475&r1=3D10474 Nice. But it would be even better to avoid the dummy, in your example let x =3D u in let y =3D v in if b then x <- v; y <- u This does not only avoid the dummy, but would also allow lowering to = "cmovcc" instructions in the backend selector (atleast for x86-32/64).=20= > -- Alain Benedikt=