
#7367: Optimiser / Linker Problem on amd64 --------------------------------------------+------------------------------ Reporter: wurmli | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.8.1 Component: Build System | Version: 7.6.1 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Runtime performance bug | (amd64) Test Case: | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: --------------------------------------------+------------------------------ Comment (by rwbarton): Replying to [comment:8 simonpj]:
I don't think `flopS` uses its continuation linearly! {{{ flopS :: Perm -> (Int -> IO a) -> IO a flopS !xs f = do let go !acc = do k <- peekElemOff xs 0 if k == 0 then f acc else flop (fromIntegral k) xs >> go (acc+1) go 0 }}}
Doesn't it though? `flopS` is just a single call to `go`, so it uses `f` linearly if `go` does. `go` performs an action unrelated to `f`, and then either it finishes by calling `f`, or it performs another action unrelated to `f` and then calls itself. So any run of `go` calls `f` exactly once, as a tail call (or it loops forever). Ah, perhaps you've misparsed `if k == 0 then f acc else flop (fromIntegral k) xs >> go (acc+1)` as `(if k == 0 then f acc else flop (fromIntegral k) xs) >> go (acc+1)`? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/7367#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler