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

2022-11-02 Thread Simon Sobisch

Am 02.11.2022 um 13:59 schrieb Torbjörn Granlund:

I seem to have misread the report.  I thought the

   movq mem,xmm

instructions were the problem.


Good that this got clearer.


I pushed a fix to the repo.  Please try it.


https://gmplib.org/repo/gmp/rev/3ac5afa36be5 works fine for me on core2.

Thank you.

Simon
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


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

2022-11-02 Thread Torbjörn Granlund
I seem to have misread the report.  I thought the

  movq mem,xmm

instructions were the problem.

I pushed a fix to the repo.  Please try it.


-- 
Torbjörn
Please encrypt, key id 0xC8601622
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


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

2022-11-02 Thread Simon Sobisch


Am 02.11.2022 um 08:58 schrieb Niels Möller:

Torbjörn Granlund  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

___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


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

2022-11-02 Thread Niels Möller
Torbjörn Granlund  writes:

> Note that the movq instances the old assembler complains about here read
> from memory.  Using movd might yield surprises there.

Hmm, it wasn't clear to me fromt he error report exactly which
instructions it was complaining about, so I guessed this was one of
them:

https://gmplib.org/repo/gmp/file/tip/mpn/x86_64/core2/hamdist.asm#l194

  movq  %xmm0, %rax

For the memory accesses, e.g., 

  movq  (up), %xmm1

I agree changing those to movd sounds scary.

Regards,
/Niels

-- 
Niels Möller. PGP key CB4962D070D77D7FCB8BA36271D8F1FF368C6677.
Internet email is subject to wholesale government surveillance.
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


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

2022-11-02 Thread Torbjörn Granlund
ni...@lysator.liu.se (Niels Möller) writes:

  So would be useful to try if replacement movq --> movd

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

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

Note that the movq instances the old assembler complains about here read
from memory.  Using movd might yield surprises there.

-- 
Torbjörn
Please encrypt, key id 0xC8601622
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


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

2022-11-02 Thread Niels Möller
Torbjörn Granlund  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

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

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

Regards,
/Niels

-- 
Niels Möller. PGP key CB4962D070D77D7FCB8BA36271D8F1FF368C6677.
Internet email is subject to wholesale government surveillance.
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


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

2022-11-01 Thread Torbjörn Granlund
Simon Sobisch  writes:

  That is an old MacBook with the most current "developer command line
  tools" that were available (from 2013/2014 if I remember correctly).

I am afraid obsolete systems might get less developer attention...

  Sigh. Sadly I don't know enough about assembly to patch it myself :-(
  But I can test because that machine is now available to me (it was
  passed to me instead of being thrown away; I did a reset, installed
  the most current software that was supported there and now try to get
  some programs running via terminal).

I know asm well, but alas, I don't know the quirks of these old tools.

If you're really eager to get these files to work, here is a cumbersome
method:

Build things on a current system.

Use objdump -dw (or otool under macos) to see the encoding for the
trouble instructions.

Replace the movq instructions with .byte sequences.  Re-compile on the
current system to make sure the objdump output stays the same.

Go back to the obsolete system and compile happily there.

-- 
Torbjörn
Please encrypt, key id 0xC8601622
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


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

2022-11-01 Thread Hans Åberg

> On 1 Nov 2022, at 22:55, Torbjörn Granlund  wrote:
> 
> Is this on a recent version of macos with current versions gcc+binutils
> installed?  Or is either old variants?

Darwin 11.4.2 is OS X 10.7.5 Lion from September 19, 2012.

https://en.wikipedia.org/wiki/OS_X_Lion


___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


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

2022-11-01 Thread Simon Sobisch

Am 01.11.2022 um 22:55 schrieb Torbjörn Granlund:

Simon Sobisch  writes:

   config.status: linking ../mpn/x86_64/core2/popcount.asm to mpn/popcount.asm
   config.status: linking ../mpn/x86_64/core2/hamdist.asm to mpn/hamdist.asm

   tmp-popcount.s:181:suffix or operands invalid for `movq'
   tmp-hamdist.s:206:suffix or operands invalid for `movq'

Is this on a recent version of macos with current versions gcc+binutils
installed?  Or is either old variants?


That is an old MacBook with the most current "developer command line 
tools" that were available (from 2013/2014 if I remember correctly).



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).


Sigh. Sadly I don't know enough about assembly to patch it myself :-(
But I can test because that machine is now available to me (it was 
passed to me instead of being thrown away; I did a reset, installed the 
most current software that was supported there and now try to get some 
programs running via terminal).


Note: running configure with ABI=32 (which leads to use of x86 instead 
of x86_64) leads to all files compiling and also all tests passing.
Therefore we at least know that the syntax used there including that old 
register to register workaround _does_ work correct with that assembler.


Thank you for getting back to me on this topic.
Simon

___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


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

2022-11-01 Thread Torbjörn Granlund
Simon Sobisch  writes:

  config.status: linking ../mpn/x86_64/core2/popcount.asm to mpn/popcount.asm
  config.status: linking ../mpn/x86_64/core2/hamdist.asm to mpn/hamdist.asm

  tmp-popcount.s:181:suffix or operands invalid for `movq'
  tmp-hamdist.s:206:suffix or operands invalid for `movq'

Is this on a recent version of macos with current versions gcc+binutils
installed?  Or is either old variants?

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).

-- 
Torbjörn
Please encrypt, key id 0xC8601622
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


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

2022-11-01 Thread Simon Sobisch

Environment:


  Version:   GNU MP 6.2.1
  Host type: core2-apple-darwin11.4.2
  ABI:   64

linked files:

config.status: linking ../mpn/x86_64/core2/popcount.asm to mpn/popcount.asm
config.status: linking ../mpn/x86_64/core2/hamdist.asm to mpn/hamdist.asm


make -k builds everything without an error but those two above fail (I 
think in gas), details see below.



When doing a research on this issue I recognized in
mpn/x86/pentium4/sse/popcount.asm
a comment "movq avoided due to gas bug" (which is in since GMP 4.3).

Maybe it is possible do do something similar for popcount.asm and 
hamdist.asm in mpn/x86_64/core2 ?




Making all in mpn
/bin/sh ../libtool --mode=compile --tag=CC ../../mpn/m4-ccas --m4="m4" 
gcc -std=gnu99 -c -DHAVE_CONFIG_H -I. -I../../mpn -I.. 
-D__GMP_WITHIN_GMP -I../.. -DOPERATION_`echo popcount | sed 's/_$//'` 
-O2 -pedantic -fomit-frame-pointer -m64 -mtune=core2 -march=core2  `test 
-f 'popcount.asm' || echo '../../mpn/'`popcount.asm
libtool: compile:  ../../mpn/m4-ccas --m4=m4 gcc -std=gnu99 -c 
-DHAVE_CONFIG_H -I. -I../../mpn -I.. -D__GMP_WITHIN_GMP -I../.. 
-DOPERATION_popcount -O2 -pedantic -fomit-frame-pointer -m64 
-mtune=core2 -march=core2 popcount.asm  -fno-common -DPIC -o 
.libs/popcount.o
m4  -DHAVE_CONFIG_H -D__GMP_WITHIN_GMP -DOPERATION_popcount -DPIC 
popcount.asm >tmp-popcount.s
 gcc -std=gnu99 -c -DHAVE_CONFIG_H -I. -I../../mpn -I.. 
-D__GMP_WITHIN_GMP -I../.. -DOPERATION_popcount -O2 -pedantic 
-fomit-frame-pointer -m64 -mtune=core2 -march=core2 tmp-popcount.s 
-fno-common -DPIC -o .libs/popcount.o

tmp-popcount.s:181:suffix or operands invalid for `movq'
make[2]: *** [popcount.lo] Error 1
/bin/sh ../libtool --mode=compile --tag=CC ../../mpn/m4-ccas --m4="m4" 
gcc -std=gnu99 -c -DHAVE_CONFIG_H -I. -I../../mpn -I.. 
-D__GMP_WITHIN_GMP -I../.. -DOPERATION_`echo hamdist | sed 's/_$//'` 
-O2 -pedantic -fomit-frame-pointer -m64 -mtune=core2 -march=core2  `test 
-f 'hamdist.asm' || echo '../../mpn/'`hamdist.asm
libtool: compile:  ../../mpn/m4-ccas --m4=m4 gcc -std=gnu99 -c 
-DHAVE_CONFIG_H -I. -I../../mpn -I.. -D__GMP_WITHIN_GMP -I../.. 
-DOPERATION_hamdist -O2 -pedantic -fomit-frame-pointer -m64 -mtune=core2 
-march=core2 hamdist.asm  -fno-common -DPIC -o .libs/hamdist.o
m4  -DHAVE_CONFIG_H -D__GMP_WITHIN_GMP -DOPERATION_hamdist -DPIC 
hamdist.asm >tmp-hamdist.s
 gcc -std=gnu99 -c -DHAVE_CONFIG_H -I. -I../../mpn -I.. 
-D__GMP_WITHIN_GMP -I../.. -DOPERATION_hamdist -O2 -pedantic 
-fomit-frame-pointer -m64 -mtune=core2 -march=core2 tmp-hamdist.s 
-fno-common -DPIC -o .libs/hamdist.o

tmp-hamdist.s:206:suffix or operands invalid for `movq'
make[2]: *** [hamdist.lo] Error 1


Thanks for any pointers,
Simon
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs