GMP 6.2.1 core2 x86_64 assembler error "operands invalid for `movq'"

Simon Sobisch simonsobisch at gnu.org
Wed Nov 2 13:30:33 CET 2022


Am 02.11.2022 um 08:58 schrieb Niels Möller:
> Torbjörn Granlund <tg at gmplib.org> writes:
> 
>> This is not the same bug as we worked around for register-to-register
>> copying on x86-32 some years ago.  It is not cleer what syntax this
>> assembler might accept, and which also gives the right instruction (here
>> and on non-prolematic hosts).
> 
> For reference, in nettle x86_64 code, there are a few places where I
> write "movd" instead of "movq" for 64-bit moves between general 64-bit
> registers and xmm registers, to work around build problems on macos.
> E.g.,
> 
> umac-nh.s:      movd    %xmm4, %rax
> sha3-permute.s: movd    %xmm15, %r9
> 
> Seems to work fine everywhere I've tested it, but I've not really
> understood why "movd" could ever be used as mnemonic for that operation
> (I also use it in other places for 32-bit moves). I guess there are some
> historic reasons.
> 
> So would be useful to try if replacement movq --> movd

Rechecked. I've changed the two occurrences of
	movq	%xmm0, %rax
https://gmplib.org/repo/gmp/file/tip/mpn/x86_64/core2/popcount.asm#l169
https://gmplib.org/repo/gmp/file/tip/mpn/x86_64/core2/hamdist.asm#l194

-	movq	%xmm0, %rax
+	movd	%xmm0, %rax

> (i) solves the problem on (older) macos, and

Works like a charm, now both assembling works on x86_64 and all internal 
tests (and all tests in gnucobol's "make checkall" which uses GMP for 
arithmetic) pass!

> (ii) produces identical object code on systems with more up-to-date
> assemblers.

As I've understood you did exactly that before in other places.

I can't test that myself because I don't have a core2 anywhere else 
currently.

> Regards,
> /Niels

Again: big thanks for pointing this out.
Open question: can this change be applied to the repo and if yes by whom?

Simon



More information about the gmp-bugs mailing list