
#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 ChaiTRex): = Semi-exhaustive testing is being performed using GHC before the fix = Using the attached program, I'm doing semi-exhaustive testing of constant folding up to an expression nesting depth of two (up to something like `(a + b)*(c + d)`) with literal and variable values in `[0, 1, 3, 7] :: [Int]`. Note that the attached program takes the better part of a day, so it might not be prudent to add it to the test suite unless that can be significantly reduced or a "very, very slow" testing option can be added. == Testing is being done before fix == To ensure the tester actually detects problems, the tester program was performed until it detected this bug report's bug with GHC before the fix (at GHC commit `ff29fc84c03c800cfa04c2a00eb8edf6fa5f4183`). The tester program is still running and full output will be attached when the program finishes. The first few lines of output are: {{{ ERROR! ((0 - x0) - (0 - x1)) is optimized incorrectly! ERROR! ((0 - x0) - (1 - x0)) is optimized incorrectly! ERROR! ((0 - x0) - (1 - x1)) is optimized incorrectly! ERROR! ((0 - x0) - (3 - x0)) is optimized incorrectly! ⋮ ⋮ ⋮ ⋮ ⋮ ⋮ ⋮ ⋮ ⋮ ⋮ ⋮ ⋮ ⋮ ⋮ ⋮ ⋮ }}} == Testing will be done after fix == Testing will next be performed using GHC at `HEAD` (after the above fix). Results will be posted in my next comment in about a day. == The program == There are two modules attached: * `ThisGHC.hs`: a Template Haskell helper module for running the specific GHC installation a program was compiled with. * `ConstantFolding.hs`: a program that repeatedly compiles a certain number of expressions at a time (to avoid heap overflows from compiling all expressions at once) with `-O2` and tests their output against those expressions compiled with `-O0`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15569#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler