Unexpected lack of optimisation in -O0

Hi, I just tried compiling the following program: foo = (1 :: Int) == (2 :: Int) with ghc --ddump-simpl, and no optimisation flags, in GHC 6.6.1 The resultant code is: Test.foo = case GHC.Base.$f2 of tpl_X8 { GHC.Base.:DEq tpl1_B2 tpl2_B3 -> tpl1_B2 (GHC.Base.I# 1) (GHC.Base.I# 2) } GHC has introduced dictionaries in this example. In comparison, Yhc and nhc wouldn't introduce dictionaries here, as the type class desugaring knows the type of the item is fixed, and makes a direct call to the appropriate function. If the desugaring was changed, it would make programs in GHCi run faster, would reduce the size of programs, and would speed up the optimiser, as it would have less to do. I am not sure how much additional work this would require in the simplifier, but if it was minimal, the gains would probably be worth it. I was just reading the Monad.Reader, where a Yhc based Haskell Interpreter states that comparisons against GHCi are "unfair", because Yhc gains too much benefit from this desguaring. Thanks Neil

Hello Neil, Thursday, April 10, 2008, 6:21:38 PM, you wrote:
I was just reading the Monad.Reader, where a Yhc based Haskell Interpreter states that comparisons against GHCi are "unfair", because Yhc gains too much benefit from this desguaring.
i believe that dictionaries is the most important point of haskell inefficiency (second one is laziness) and this feature may allow ghci/ghc-O0 to became much faster -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com
participants (2)
-
Bulat Ziganshin
-
Neil Mitchell