
#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