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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 5BCBFBC57 for ; Wed, 15 Dec 2010 14:15:55 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvwAAOdNCE3RVdU2kGdsb2JhbACVeYEljQAIFgECCQkMBxEEIKdzjAgBBY4ZAQSFSg X-IronPort-AV: E=Sophos;i="4.59,348,1288566000"; d="scan'208";a="70713973" Received: from mail-yw0-f54.google.com ([209.85.213.54]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-MD5; 15 Dec 2010 14:15:54 +0100 Received: by ywp6 with SMTP id 6so1091687ywp.27 for ; Wed, 15 Dec 2010 05:15:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:from:to:references :in-reply-to:subject:date:organization:message-id:mime-version :content-type:content-transfer-encoding:x-mailer:thread-index :content-language; bh=DgkYN3mO2uPsKlFOfR+37UfY2oEub9HjYTawvFrM2JA=; b=AGrZMHIZ1r66XFgXUhMjIYKpts3diXbGeTkNxxGLnHpNw7tv9JjdXpY6M74glmDZ7l DQbMjccinjSflcPVz+/w7cS8vEvw6YnolqAs45SUsnXJqWBTm3QBaZj3ObL7ocYTaGQx 6hFlkRlJBMwT+djrxv67EzXTu+W3U0mcl1EoY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=from:to:references:in-reply-to:subject:date:organization:message-id :mime-version:content-type:content-transfer-encoding:x-mailer :thread-index:content-language; b=KrX9PEDkuwHKK0uJ1E1duFLlcTbNCQLn3hBlI23+IzWjLSZvkNmjTP7xOuW+5bOu8p UKqXoXguDGOHqsvRt6uDxcnHazff7tIMF5ZjqaCfxFSSA4WP7j2eTofL8AS6dbv/vYAE 63anpb4Zg1+Jw85SWjedTOKYYSh6XwnOpgo4A= Received: by 10.216.238.130 with SMTP id a2mr766491wer.77.1292418953064; Wed, 15 Dec 2010 05:15:53 -0800 (PST) Received: from WinEight ([84.93.149.66]) by mx.google.com with ESMTPS id o51sm901775wes.15.2010.12.15.05.15.50 (version=SSLv3 cipher=RC4-MD5); Wed, 15 Dec 2010 05:15:51 -0800 (PST) From: Jon Harrop To: References: <036001cb9a0c$725acef0$57106cd0$@com> <20101212175524.73a8e285@deb0> <9264BEE6-DBAE-4523-93AC-4560615D2AC5@googlemail.com> <4D05DCB6.2060100@frisch.fr> <85AB623B-0278-41F0-9C70-8E8814C0A16F@googlemail.com> In-Reply-To: <85AB623B-0278-41F0-9C70-8E8814C0A16F@googlemail.com> Subject: RE: Value types (Was: [Caml-list] ocamlopt LLVM support) Date: Wed, 15 Dec 2010 13:15:26 -0000 Organization: Flying Frog Consultancy Message-ID: <052601cb9c5a$2604a760$720df620$@com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: AcucQvybfAnyfl1uS9yujprEs1XNiwAFYH5A Content-Language: en-gb X-Spam: no; 0.00; ocamlopt:01 fwiw:01 structs:01 structs:01 recursion:01 unboxed:01 cheers:01 polymorphic:01 wrote:01 caml-list:01 tuples:01 tuples:01 library:03 let:03 let:03 Benedikt wrote: > Nice. But it would be even better to avoid the dummy, in your example > > let x = u in > let y = 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). FWIW, when you're using LLVM (as a library!) to generate equivalent code then you can just represent the tuples as structs (value types) and LLVM will take care of all of this for you. Again, it generates really efficient code with minimal effort. The latest example front-end for HLVM represents tuples as structs so it gets this for free. However, polymorphic recursion is *much* harder to implement with that design choice. Also, there is the question of when boxed vs unboxed tuples are more efficient. Cheers, Jon.