cabal dist discourages you from using -O2 since it produces longer compile times and the GHC manual says:
At the moment,
-O2is unlikely to produce better code than-O.
I know that I can always benchmark the library to see if -O2 gives better performance, but I was wondering if somebody could explain what -O2 does different from -O so I could get an intuition for why they consider it unlikely to produce better code.
-O2 performs the constructor specialization. There are some other optimizations that are only enabled at -O2 as well, including -fliberate-case, -fstatic-argument-transformation,
I have a suspicion that -O2 now always produces better code, since that recommendation dates back about 10 years.
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