-optc-O2 considered useful
marlowsd at gmail.com
Fri May 16 05:38:46 EDT 2008
Don Stewart wrote:
>> On Thu, 2008-05-15 at 23:00 +0400, Bulat Ziganshin wrote:
>>> Hello Don,
>>> Thursday, May 15, 2008, 10:47:20 PM, you wrote:
>>>> I discovered something today I didn't know.
>>>> gcc -O2 can optimise out the computed jumps GHC produces in tight loops.
>>> seems that decision to use native backend in ghc -O2 was too early?
>> Though note that the native backend never introduced the computed jump.
>> I think it's clear that -fvia-C -O should imply -optc-O2 if it does not
>> already. gcc -O0 is for painfully obvious C translation into assembler,
>> -O is for quick optimisations. gcc -O2 is the "standard" optimisation
>> level used for building packages for most distros.
> Another idea:
> should -fstrictness be on by default?
> I run into too many users writing little tail recursive Int loops, and
> not using optimisations, with the impression that compiling, e.g.
> ghc A.hs
> should just work.
This is part of a larger question, namely whether we can get substantial
benefit for doing a tiny bit of extra work in -O0. With -O0 we're
optimising for compile time in preference to code speed, although we do
want to find a good compromise that doesn't generate abysmal code. I bet
there are things we can do with -O0 that would generate significantly
better code in some cases, without increasing compile times, and perhaps
even decreasing compile times due to the reduction in the amount of code
As for the specific issue of whether we should turn on -fstrictness with
-O0, I suspect the answer is that the compile-time cost would be too high.
More information about the Glasgow-haskell-users