[Haskell-cafe] GHC optimisations

Tim Chevalier catamorphism at gmail.com
Sun Aug 19 13:48:32 EDT 2007


On 8/19/07, Andrew Coppin <andrewcoppin at btinternet.com> wrote:
> Does GHC do stuff like converting (2*) into (shift 1) or converting x +
> x into 2*x?
>

Hmm, that's an interesting architecture where multiplication is
cheaper than addition :-)

> If I do x * sin 12, is GHC likely to compute sin 12 at compile-time?
>

I seriously doubt it, but there's an easy way to find out the answer
to all these questions: pass the -ddump-simpl flag to GHC so that it
prints out the intermediate code it generates. There's some
information in the users' guide about how to read the results.

Cheers,
Tim

-- 
Tim Chevalier * catamorphism.org * Often in error, never in doubt
"I always wanted to be commander-in-chief of my own one-woman army" --
Ani DiFranco


More information about the Haskell-Cafe mailing list