Open conal opened 7 years ago
This example comes from compiling toEnum @Bool
:
lam Case of boxer: bare unboxed var
case n_ahgh of _ [Occ=Dead] { I# x_ahgk ->
case x_ahgk of _ [Occ=Dead] {
__DEFAULT -> $fEnumBool1;
0# -> False;
1# -> True
}
}
The issue arises from unlifted literal alternatives. Haskell does not have lifted literal alternatives except for Integer.
https://github.com/ghc/ghc/blob/master/compiler/coreSyn/CoreSyn.hs
Given that is the case, a reasonable solution would seem to be to convert the unlifted variables into lifted Integer and then convert each alternative to a literal Integer alternative. For many cases, this is trivial because the internal representation is also an Integer. For the case of Double and Float, they are represented as Rational, so it will be necessary to convert the Rational (two Integer) to a single Integer (probably using some bit shifting and or-ing them together).
I fixed case-of-Int#
in 6af4d1a6aaa1117964e78710c011ce711d4ae6b8, with some improvements over the next few commits.
The reboxing scheme described in section 10.1 of Compiling to categories sometimes fails. Collect examples here, and mull over improved schemes.