#2388: GHC creates invalid test instruction for 64-bit code
----------------------------------+-----------------------------------------
Reporter: MartinGrabmueller | Owner:
Type: bug | Status: new
Priority: normal | Component: Compiler
Version: 6.8.2 | Severity: normal
Keywords: | Testcase:
Architecture: x86_64 (amd64) | Os: Linux
----------------------------------+-----------------------------------------
When compiling the cpuid package from Hackage (http://hackage.haskell.org
/cgi-bin/hackage-scripts/package/cpuid), Don Stewart noticed
that compilation aborts on a 64-bit Linux box with the following error
message:
{{{Error: suffix or operands invalid for `test'}}}
Examining the assembler code, we see that the instruction
`testq $2147483648,%rax`
is generated, but `test` is only allowed to take a 32-bit immediate
operand.
Don's compilation info follows:
{{{
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 6.8.2
$ gcc --version
gcc (GCC) 4.3.1
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
$ uname -msr
Linux 2.6.25-ARCH x86_64
$ cabal install cpuid
Resolving dependencies...
Downloading cpuid-0.2...
Configuring cpuid-0.2...
Preprocessing library cpuid-0.2...
Building cpuid-0.2...
[1 of 1] Compiling System.Cpuid ( System/Cpuid.hs,
dist/build/System/Cpuid.o )
/tmp/ghc23771_0/ghc23771_0.s: Assembler messages:
/tmp/ghc23771_0/ghc23771_0.s:3254:0:
Error: suffix or operands invalid for `test'
cabal: Error: some packages failed to install:
cpuid-0.2 failed during the building phase. The exception was:
exit: ExitFailure 1
Checking the temp files, this is generated:
$ runhaskell Setup.lhs configure --ghc-options=-keep-tmp-files
$ runhaskell Setup.lhs build
Preprocessing library cpuid-0.2...
Building cpuid-0.2...
[1 of 1] Compiling System.Cpuid ( System/Cpuid.hs,
dist/build/System/Cpuid.o )
/tmp/ghc9500_0/ghc9500_0.s: Assembler messages:
/tmp/ghc9500_0/ghc9500_0.s:3254:0:
Error: suffix or operands invalid for `test'
$ vim /tmp/ghc9500_0/ghc9500_0.s +3254
s3TR_info:
addq $208,%r12
cmpq %r15,%r12
ja .Lc3W2
movq 7(%rbx),%rax
testq $2147483648,%rax
je .Lc3W4
movq 8(%rbp),%rsi
addq $16,%rbp
addq $-208,%r12
jmp r2By_info
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2388>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs