Version française
Home     About     Download     Resources     Contact us    
Browse thread
Pervasives.{min,max} not specialized to floats by ocamlopt
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Will M Farr <farr@M...>
Subject: Pervasives.{min,max} not specialized to floats by ocamlopt
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