
#15569: Constant folding optimises 1 into 3 -------------------------------------+------------------------------------- Reporter: snowleopard | Owner: (none) Type: bug | Status: new Priority: highest | Milestone: 8.6.1 Component: Compiler | Version: 8.6.1-beta1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #9136 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by snowleopard): In an attempt to find a safer implementation for constant folding I came up with this: https://gist.github.com/snowleopard/2dd93951cfd42e03aa04a4aa696ca029 This may be an overkill, but does shift most of the verification load to the compiler: we still need to manually verify a few key functions like `eval`, but the constant folding rules can't be written incorrectly. NB: I covered most of the rules, but not all. Also I haven't really shown what to do with negative variables (non-literals) in the end, but this bit doesn't look too complicated. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15569#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler