[GHC] #149: missed CSE opportunity
GHC
trac at galois.com
Thu Oct 12 14:48:17 EDT 2006
#149: missed CSE opportunity
------------------------------+---------------------------------------------
Reporter: nobody | Owner: nobody
Type: bug | Status: assigned
Priority: low | Milestone: _|_
Component: Compiler | Version: 5.04.2
Severity: normal | Resolution: None
Keywords: optimisations | Difficulty: Unknown
Architecture: Unknown | Os: Unknown
------------------------------+---------------------------------------------
Changes (by igloo):
* architecture: => Unknown
* difficulty: => Unknown
* milestone: => _|_
* keywords: => optimisations
* os: => Unknown
Old description:
> {{{
> Don't know if this is a bug, but it was at least
> _surprising_ to find that
>
> playerMostOccur [a] = a
> playerMostOccur (x:xs)| numOccur x (x:xs)
> >
> numOccur
> (playerMostOccur xs) xs
> = x
> | otherwise =
> playerMostOccur xs
>
> was exponentially slower when compiled with ghc-5.04.2
> -O than:
>
> playerMostOccur [a] = a
> playerMostOccur (x:xs)| numOccur x (x:xs)
> >
> numOccur pmo xs
> = x
> | otherwise = pmo
> where pmo =
> playerMostOccur xs
>
> Although the student responsible for the code couldn't
> spot the
> obvious optimisation, I was expecting that GHC's
> optimiser would. :)
> If it's not a bug, could you explain it to me?
>
> -Greg(gregm.at.cs.uwa.edu.au)
> }}}
New description:
{{{
Don't know if this is a bug, but it was at least
_surprising_ to find that
playerMostOccur [a] = a
playerMostOccur (x:xs)| numOccur x (x:xs)
>
numOccur
(playerMostOccur xs) xs
= x
| otherwise =
playerMostOccur xs
was exponentially slower when compiled with ghc-5.04.2
-O than:
playerMostOccur [a] = a
playerMostOccur (x:xs)| numOccur x (x:xs)
>
numOccur pmo xs
= x
| otherwise = pmo
where pmo =
playerMostOccur xs
Although the student responsible for the code couldn't
spot the
obvious optimisation, I was expecting that GHC's
optimiser would. :)
If it's not a bug, could you explain it to me?
-Greg(gregm.at.cs.uwa.edu.au)
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/149>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list