cmmMachOpFoldM: unknown unary op: MO_XX_Conv W8 W64
Summary
I thought I'd give a shot at creating all the common instances for new primitives Int8#
, etc. and see how they compare performance wise to what we have now. In the process of doing so I got a GHC panic and another assembly error, which I can't really narrow down to an exact place, but a fully reproducible piece of code is attached. I suspect there might really be two different bugs here at play, but considering they happen on the same piece of new functionality I thought they might be related.
This is the error I get:
ghc: panic! (the 'impossible' happened)
(GHC version 8.10.1:
cmmMachOpFoldM: unknown unary op: MO_XX_Conv W8 W64
Another problem I get is when I replace divInt8#
with this:
divInt8# :: Int8# -> Int8# -> Int8#
x# `divInt8#` y#
| isTrue# (x# `gtInt8#` zero#) && isTrue# (y# `ltInt8#` zero#) =
((x# `subInt8#` one#) `quotInt8#` y#) `subInt8#` one#
| isTrue# (x# `ltInt8#` zero#) && isTrue# (y# `gtInt8#` zero#) =
((x# `plusInt8#` one#) `quotInt8#` y#) `subInt8#` one#
| otherwise = x# `quotInt8#` y#
where
zero# = narrowInt8# 0#
one# = narrowInt8# 1#
I also get this error message from gcc:
[1 of 2] Compiling MyInt8 ( MyInt8.hs, MyInt8.o )
/tmp/ghc7105_0/ghc_2.s: Assembler messages:
/tmp/ghc7105_0/ghc_2.s:634:0: error:
Error: invalid instruction suffix for `lea'
|
634 | leab -1(%r14),%bl
| ^
/tmp/ghc7105_0/ghc_2.s:650:0: error:
Error: invalid instruction suffix for `lea'
|
650 | leab 1(%r14),%bl
| ^
/tmp/ghc7105_0/ghc_2.s:677:0: error:
Error: invalid instruction suffix for `lea'
|
677 | leab 1(%r14),%bl
| ^
`gcc' failed in phase `Assembler'. (Exit code: 1)
Steps to reproduce
Splitting into two modules seemed to be necessary and it is important to compile with optimization turned on.
$ ghc int8.hs -O1 -fforce-recomp
[1 of 2] Compiling MyInt8 ( MyInt8.hs, MyInt8.o )
[2 of 2] Compiling Main ( int8.hs, int8.o )
ghc: panic! (the 'impossible' happened)
(GHC version 8.8.3 for x86_64-unknown-linux):
cmmMachOpFoldM: unknown unary op: MO_XX_Conv W8 W64
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
Files to reproduce the bug(s):
A full repro is also available in this repo: https://github.com/lehins/bugs/tree/master/haskell/ghc-int8
Expected behavior
Compile into correct binary without errors
Environment
- GHC version used: 8.8.3 and 8.10.1
Optional:
- Operating System: Ubuntu 18.04
- System Architecture: x86_64