user manual: INLINE's interaction with optimization levels is not clear
From the user manual it's not possible to say how should INLINE and actual inlining behavior should interact with optimization levels.
What the user manuals says:
-
Without INLINE GHC tries to inline depending on size of definitions and current optimization level(user manual says -O is needed, but can we assume that for any inlining to be done we need at least -O? Because I have an example in which inlining is happening even with -O0).
-
With INLINE GHC tries hard to inline. But it doesn't say which optimization level is needed.
I think we should add word or two about this. Does anyone know the answer here?
My guess is: Even though INLINE makes sure GHC saves RHS of the definition in .hi files to be able to inline later, optimization levels still have an effect on deciding whether to inline or not. Because some INLINEd RHSs may be too big in which case it may decide not to inline with -O1 but inline with -O2 etc.
Furthermore, without -O, GHC doesn't mark definitions as INLINE. But if we have INLINEd definitions and compiling a code with -O0, it may still inline those definitions, because there are two different mechanisms to decide whether to mark as INLINE and whether to inline the RHS, and while without -O GHC doesn't mark anything as INLINE, it can still inline previously marked definitions.