The title is a slight joke.
I just discovered today that ghc accepts any optimization level without complaining. I know that -O2 is supposed to be the maximum optimization level, and that there is a proposed -O3 here, but I was just curious what happens when you mistakenly specify an even higher optimization level. Does ghc default to -O2 or does it not optimize at all?
It looks like it is clamped to be between 0 and 2 in compiler/main/DynFlags.hs:
updOptLevel :: Int -> DynFlags -> DynFlags
-- ^ Sets the 'DynFlags' to be appropriate to the optimisation level
updOptLevel n dfs
= dfs2{ optLevel = final_n }
where
final_n = max 0 (min 2 n) -- Clamp to 0 <= n <= 2
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With