Skip to content

Local binding gets inlined even with -O0 and -fmax-simplifier-iterations=0

Given the following module:

{-# OPTIONS_GHC -fforce-recomp #-}
{-# OPTIONS_GHC -O0 #-}
{-# OPTIONS_GHC -fno-omit-interface-pragmas #-}
{-# OPTIONS_GHC -fmax-simplifier-iterations=0 #-}

module Foo where

foo :: Bool
foo = f False undefined
  where f x _ = x
{-# INLINABLE foo #-}

In the interface file the unfolding of foo is False, which means f is inlined and reduced.

Since we are compiling with -O0 and -fmax-simplifier-iterations=0, I don't understand where and how the inlining of f happens. I thought even unconditional inlining wouldn't fire with those flags.

Outside of adding {-# NOINLINE f #-}, is it possible to turn it off so that we get let f = ... in ... as foo's unfolding? I was using GHC 9.2.7.

Edited by Ziyang Liu
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information