[GHC] #13334: Constant folding for repeated integer operation of unknown value
GHC
ghc-devs at haskell.org
Fri Feb 24 21:18:04 UTC 2017
#13334: Constant folding for repeated integer operation of unknown value
-------------------------------------+-------------------------------------
Reporter: bgamari | Owner: (none)
Type: feature | Status: new
request |
Priority: low | Milestone:
Component: Compiler | Version: 8.0.1
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: Runtime
Unknown/Multiple | performance bug
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
While looking at Phab:D3197 I noticed that currently there is nothing to
turn an expression of the form `n+n+...+n` into `n*m`. It seems like some
rules like,
{{{
forall x. x +# x = 2*x
forall n x. n*x + x = (n+1) * x
forall n x. x + n*x = (n+1) * x
}}}
Might fix this. Of course, it's quite possible that a string of additions
**is** sometimes faster than a multiplication, but it seems to me that we
should (for integer types) perform the rewrite to multiplication and then
teach the code generator to lower to addition if it deems it advantageous.
Naturally, this also applies to other integer operators as well.
Regardless, I doubt that this is hurting anyone too badly.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13334>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list