Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Register
  • Sign in
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
    • Locked files
  • Issues 5.6k
    • Issues 5.6k
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 660
    • Merge requests 660
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
    • Test cases
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Model experiments
  • Analytics
    • Analytics
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #683

RULES for recursive functions don't work properly

someone mentioned to me that this expression:

mapM_ action [n..m]

isn't being optimised properly, so I thought I'd look into it. Sure enough, we don't get down to a simple loop like we should, although the F/B transformation is happening (see ~simonmar/scratch/mapm.hs). The problem is that GHC.Enum.eftIntFB isn't being inlined, it's defined like this:

{-# INLINE [0] eftIntFB #-}
eftIntFB :: (Int -> r -> r) -> r -> Int# -> Int# -> r
eftIntFB c n x y | x ># y    = n	
		 | otherwise = go x
		 where
		   go x = I# x `c` if x ==# y then n else go (x +# 1#)

but, strangely, the inlining doesn't appear in the interface:

eftIntFB :: (GHC.Base.Int -> r -> r) -> r -> GHC.Prim.Int# -> GHC.Prim.Int# -> r
  {- Arity: 4 HasNoCafRefs Strictness: LLLL -}

This is becuase the RULE make eftIntFB look recursive, so its inlining isnt' exposed. Bad, bad.

Edited Mar 09, 2019 by Simon Peyton Jones
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking