#5237: Inefficient code generated for x^2
--------------------------------------+-------------------------------------
Reporter: scpmw | Owner:
Type: bug | Status: new
Priority: normal | Milestone: 7.4.1
Component: libraries/base | Version: 7.0.3
Resolution: | Keywords:
Testcase: | Blockedby:
Difficulty: | Os: Linux
Blocking: | Architecture: x86_64 (amd64)
Failure: Runtime performance bug |
--------------------------------------+-------------------------------------
Comment(by simonpj):
I finally get it. What we ''want'' to say is
{{{
{-# RULES "^^^2/Integer" forall x. x ^^^ (2 :: Integer) = x * x #-}
{-# SPECIALISE [1] (^^^) :: Integer -> Integer -> Integer #-}
}}}
Note the `[1]` for SPECIALISE, saying "only run the specialise rule in
phase 1 and later. So the RULE gets a chance to run in the earlier phase
2.
This is the right way to solve this, not by making rules override
specialisation; that's far too fragile.
But on looking at GHC I see that SPECIALISE pragmas don't let you specify
a phase in which they become active. That's just a stupid oversight; like
any RULE or INLINE pragma, it should definitely have a phase control.
That would let you solve the problem, right?
Simon
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5237#comment:17>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs