-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
GHC panics on the following program:
module Test where
import Numeric.FastMath
import GHC.Exts
times4 :: Double -> Double
times4 (D# x) = D# ((x *## x) *## (x *## x))
ghc-7.10.1 Test.hs -cpp -XMagicHash -O -fforce-recomp
...
[5 of 5] Compiling Test ( Test.hs, Test.o )
ghc: panic! (the 'impossible' happened)
(GHC version 7.10.1 for x86_64-unknown-linux):
Simplifier ticks exhausted
When trying RuleFired double commute left *
To increase the limit, use -fsimpl-tick-factor=N (default 100)
If you need to do this, let GHC HQ know, and what factor you needed
To see detailed counts use -ddump-simpl-stats
Total ticks: 4564
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
It is not a bug in GHC though. It happens because of the following rewrite rule in Numeric.FastMath.Approximation
"double commute left *" [~2] forall x1 x2 x3. (*##) x1 ((*##) x2 x3)
= (*##) ((*##) x2 x3) x1
This rewrites (x *## x) *## (x *## x) to (x *## x) *## (x *## x).
From the GHC user's guide [1]:
GHC makes no attempt to make sure that the rules are confluent or terminating. For example:
"loop" forall x y. f x y = f y x
This rule will cause the compiler to go into an infinite loop.
The are similar fragile rewrite rules in this package. I don't know what to about this, other than to remove those rules. Or at least put a big warning in the README.
[1] https://downloads.haskell.org/~ghc/7.10.1/docs/html/users_guide/rewrite-rules.html#rule-semantics
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels