[Haskell-cafe] Re: Documenting the impossible

Peter Hercek phercek at gmail.com
Sat Jun 14 18:12:26 EDT 2008


Andrew Coppin wrote:
<-- cut -->
> When compiled without optimisations, the pragma just causes an exception 
> to be thrown, rather like "error" does. When compiled with 
> optimisations, the whole case alternative is removed, and no code is 
> generated for it. (And if the impossible somehow happens... behaviour is 
> undefined.)

So if the compiler optimizes otherwise well you save how much? Something like:
  * one load from cache (since the next is the pointer which will be needed
    anyway later and moreover it was created just few insturctions before);
    almost always should be in L1; so lets say 2 or 3 ticks; moreover this
    applies only when you do not tag pointers (which can be done for Maybe)
  * run test instruction on it; 1 tick
  * conditional jump; should be doable so that it is predicted correctly by
    default - so you get 1 tick here probably too

So you want to save somewhere about 2 to 5 ticks (which with a bit of luck
  can be shared with other instructions) but you get unsafe execution.
  Does not sound right to me. There should be other optimizations which can
  be done and which save more.
If it is ever done I hope it will be possible to switch it off. Or the
  compiler must prove that what I think is impossible is really impossible
  and then it can do it :-D

Peter.



More information about the Haskell-Cafe mailing list