[GHC] #11344: Rule "and/build" not firing

#11344: Rule "and/build" not firing -------------------------------------+------------------------------------- Reporter: j.waldmann | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.3 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: -------------------------------------+------------------------------------- For this function {{{ isprime_1 :: Int -> Bool isprime_1 n = n >= 2 && ( and $ map (\t -> 0 < mod n t) $ [2 .. truncate $ sqrt $ fromIntegral n] ) }}} rule "and/build" is not firing with ghc-7.10.3. ghc-7.8.4 does fire the rule and produces much better (that is, non- allocating) code. I can get good code with 7.10 if I replace "and" by {{{ import GHC.Base (build) {-# RULES "und/build" forall (g::forall b.(Bool->b->b)->b->b) . und (build g) = g (&&) True #-} {-# NOINLINE und #-} und :: [Bool] -> Bool und = foldr (&&) True }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11344 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11344: Rule "and/build" not firing -------------------------------------+------------------------------------- Reporter: j.waldmann | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.10.3 Resolution: duplicate | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #9848 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by nomeata): * status: new => closed * resolution: => duplicate * related: => #9848 Comment: This is a regression due to BBP: `and` no longer is `GHC.OldList.and` (if you import that, it works), but rather {{{ and :: Foldable t => t Bool -> Bool and = getAll #. foldMap All }}} `foldMap` has been modified to fuse better since then, see #9848. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11344#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11344: Rule "and/build" not firing -------------------------------------+------------------------------------- Reporter: j.waldmann | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.10.3 Resolution: duplicate | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #9848 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Can someone check if the fix to #9848 fixes this ticket too? ANd add a regression test? Thanks Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11344#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11344: Rule "and/build" not firing -------------------------------------+------------------------------------- Reporter: j.waldmann | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.10.3 Resolution: duplicate | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #9848 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by nomeata): I did check, it fixes this (that’s why I closed it). Also, that ticket has a regression test for `and`. I think we are fine (besides slightly shamed that it is broken in 7.10). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11344#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC