
#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): I've started reworking my code to generate a small subset of test cases that use one specific fixed constant (100^th^ prime, 200^th^ prime, ''etc''. to avoid coincidentally passing tests) for each spot where a literal or variable is expected, which should cut down significantly on the number of tests. I'd like to further cut down on the number of tests while still getting full coverage, but I've only skimmed some of the constant folding rules. Am I right in assuming that the following are true? * `Int`s are the only type we need to test (if this isn't true, my reworking will make the code take a type parameter, so generating tests for additional types will be simple). * The following expression shapes are the only ones required, where `∘` is multiplication, addition, or subtraction and where multiple occurrences in one expression can represent different operations. '''Note:''' negation stops after single-`∘` expressions: * `a` * `-a` * `a ∘ b` * `a ∘ -b` * `-a ∘ b` * `a ∘ (b ∘ c)` * `(a ∘ b) ∘ c` * `(a ∘ b) ∘ (c ∘ d)` -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15569#comment:18 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler