[GHC] #13172: scrutinee constant folding produces wrong answer when remapped values are out of bounds
#13172: scrutinee constant folding produces wrong answer when remapped values are out of bounds -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new Priority: highest | Milestone: Component: Compiler | Version: 8.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- This program should output 2, but in 8.1 with `-O` enabled it outputs 3. The problem is with the way that scrutinee constant folding rewrites the case. {{{#!hs f :: Word -> Word f n = case n+1 of 0 -> 2 _ -> 3 {-# NOINLINE f #-} main = print (f (-1)) }}} Core with 8.1 and `-O`: {{{ f [InlPrag=NOINLINE] :: Word -> Word [GblId, Arity=1, Caf=NoCafRefs, Str=<S(S),1*U(1*U)>m] f = \ (n_ay2 :: Word) -> case n_ay2 of { GHC.Types.W# x#_a1SL -> case x#_a1SL of { __DEFAULT -> lvl_r4lD; -1## -> lvl1_r4mD } } }}} Apparently `-1##` isn't okay: it needs to be `9223372036854775807##`. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13172> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13172: scrutinee constant folding produces wrong answer when remapped values are out of bounds -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: patch Priority: highest | Milestone: Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3009 Wiki Page: | -------------------------------------+------------------------------------- Changes (by hsyl20): * status: new => patch * differential: => Phab:D3009 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13172#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13172: scrutinee constant folding produces wrong answer when remapped values are out of bounds -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: patch Priority: highest | Milestone: Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3009 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"53e2e70a477896d57059b5f12147b69d22a2e2e0/ghc" 53e2e70a/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="53e2e70a477896d57059b5f12147b69d22a2e2e0" Ensure that scrutinee constant folding wraps numbers Test Plan: T13172 Reviewers: rwbarton, simonpj, austin, bgamari Reviewed By: simonpj, bgamari Subscribers: simonpj, thomie Differential Revision: https://phabricator.haskell.org/D3009 GHC Trac Issues: #13172 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13172#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13172: scrutinee constant folding produces wrong answer when remapped values are out of bounds -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: closed Priority: highest | Milestone: 8.2.1 Component: Compiler | Version: 8.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3009 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => closed * resolution: => fixed * milestone: => 8.2.1 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13172#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC