
#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): Phab:D5109 Wiki Page: | -------------------------------------+------------------------------------- Comment (by monoidal): I picked all rules from D2858, including the wrong and the correct version of `(L y :-: v) :-: (L x :-: w)` and used sympy to compute the difference between LHS and RHS symbolically. Result: all differences simplify to 0, except that one rule that was found to be wrong. Code: https://gist.github.com/monoidal/3d5565b986a013639389fc57081d2781 All of the rules use addition, subtraction and multiplication only (matters would be different if there was division). This makes me confident that the rules are algebraically correct. It doesn't mean the code is completely correct, but any remaining errors will be of different nature. If someone is willing to do further review, I would suggest things like: double-checking the code surrounding the rules, checking if integer overflow can occur, does this apply only to Int/Integer or other types etc. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15569#comment:20 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler