[Haskell-cafe] Re: Haskell performance (again)!

Lennart Augustsson lennart at augustsson.net
Tue Oct 10 18:30:32 EDT 2006


On Oct 10, 2006, at 14:58 , Jón Fairbairn wrote:

> Bulat Ziganshin <bulat.ziganshin at gmail.com> writes:
>
>> Hello Jon,
>>
>> Tuesday, October 10, 2006, 1:18:52 PM, you wrote:
>>
>>> Surely all but one of the comparisons is unnecessary? If you
>>> use `compare` instead of (==) and friends, won't one do (I'm
>>> assuming that the compiler can convert cases on LT, EQ and
>>> GT into something sensible -- after all, wasn't that the
>>> purpose of compare?)?
>>
>> it will too smart for GHC. actual code is:
>>
>> compareInt# :: Int# -> Int# -> Ordering
>> compareInt# x# y#
>>     | x# <#  y# = LT
>>     | x# ==# y# = EQ
>>     | otherwise = GT
>
> But once that's been inlined and through whatever code
> generator, what then? If it doesn't get turned into one test
> on the data and conditional jumps on sign bits, something
> isn't doing a thorough job...

Assuming your machine architecture supports something like condition  
codes.  On, e.g., the MIPS you would need to test for < and ==  
separately.

	-- Lennart



More information about the Haskell-Cafe mailing list