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 nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 15039BB83 for ; Fri, 18 Aug 2006 16:45:03 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k7IEiF5v017512 for ; Fri, 18 Aug 2006 16:45:02 +0200 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id QAA12632 for ; Fri, 18 Aug 2006 16:32:48 +0200 (MET DST) Received: from biscayne-one-station.mit.edu (BISCAYNE-ONE-STATION.MIT.EDU [18.7.7.80]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id k7HIYOeb005242 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 17 Aug 2006 20:34:25 +0200 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by biscayne-one-station.mit.edu (8.13.6/8.9.2) with ESMTP id k7HIYNr8006578 for ; Thu, 17 Aug 2006 14:34:23 -0400 (EDT) Received: from [18.75.3.69] (CSR-DYN-69.MIT.EDU [18.75.3.69]) (authenticated bits=0) (User authenticated as farr@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id k7HIYEkQ021452 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Thu, 17 Aug 2006 14:34:15 -0400 (EDT) Mime-Version: 1.0 (Apple Message framework v752.2) Content-Transfer-Encoding: 7bit Message-Id: <5EAC544C-8B6E-4004-B817-20190E868A3B@MIT.edu> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed To: caml-list@inria.fr From: Will M Farr Subject: Pervasives.{min,max} not specialized to floats by ocamlopt Date: Thu, 17 Aug 2006 14:34:14 -0400 X-Mailer: Apple Mail (2.752.2) X-Scanned-By: MIMEDefang 2.42 X-Miltered: at concorde with ID 44E4B6B0.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; pervasives:01 ocamlopt:01 ocamlopt:01 val:01 inference:01 pervasives:01 val:01 bug:01 surprising:01 polymorphic:01 functions:01 functions:01 floats:02 floats:02 seems:03 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 Hello all, I was profiling some numerical code compiled with ocamlopt today (for the record: PPC G4, Mac OS X 10.4.7, ocamlopt 3.09.2), and I noticed that a lot of time was taken up in the compare_val function, even though type inference asserted that all values I was comparing were floats. Turns out the culprits were Pervasives.min and Pervasives.max---these functions do not specialize to the appropriate assembly instructions if their arguments are known to be floats. Including my own min and max functions in the module to shadow these removed the calls to compare_val. I'm curious if this is well-known behavior (a google search didn't turn up anything). It's, of course, not a bug, but it's definitely surprising when all the other polymorphic comparisons are special-cased for floats! I don't know how hard it would be to change this in ocamlopt, but it seems like it would be pretty simple. If it is simple, it would be a good candidate to change in the next release for those of us who do a lot of float-comparing. Thanks! Will