diff options
author | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2021-09-26 13:55:55 +0200 |
---|---|---|
committer | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2021-09-26 13:55:55 +0200 |
commit | 359261743cc5d2ec1e3bcae6a84da1e5b8fa07b2 (patch) | |
tree | 377a3121de9c65152eb6fbe63b92faf4bd4bab2b /mpz | |
parent | c4e474311f89c51ff8d0c9dcb13ef4e3a4d0e40e (diff) | |
download | gmp-359261743cc5d2ec1e3bcae6a84da1e5b8fa07b2.tar.gz |
mpz/import.c: Use MPN_BSWAP_REVERSE, reorder branches
Diffstat (limited to 'mpz')
-rw-r--r-- | mpz/import.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/mpz/import.c b/mpz/import.c index e40b5ed57..ad909d2f7 100644 --- a/mpz/import.c +++ b/mpz/import.c @@ -1,6 +1,6 @@ /* mpz_import -- set mpz from word data. -Copyright 2002, 2012 Free Software Foundation, Inc. +Copyright 2002, 2012, 2021 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -64,36 +64,33 @@ mpz_import (mpz_ptr z, size_t count, int order, /* Can't use these special cases with nails currently, since they don't mask out the nail bits in the input data. */ - if (nail == 0 && GMP_NAIL_BITS == 0) + if (nail == 0 && GMP_NAIL_BITS == 0 + && size == sizeof (mp_limb_t) + && (((char *) data - (char *) NULL) % sizeof (mp_limb_t)) == 0 /* align */) { - unsigned align = ((char *) data - (char *) NULL) % sizeof (mp_limb_t); - - if (order == -1 - && size == sizeof (mp_limb_t) - && endian == HOST_ENDIAN - && align == 0) + if (order == -1 && endian == HOST_ENDIAN) { MPN_COPY (zp, (mp_srcptr) data, (mp_size_t) count); goto done; } - if (order == -1 - && size == sizeof (mp_limb_t) - && endian == - HOST_ENDIAN - && align == 0) + if (order == -1 && endian == - HOST_ENDIAN) { MPN_BSWAP (zp, (mp_srcptr) data, (mp_size_t) count); goto done; } - if (order == 1 - && size == sizeof (mp_limb_t) - && endian == HOST_ENDIAN - && align == 0) + if (order == 1 && endian == HOST_ENDIAN) { MPN_REVERSE (zp, (mp_srcptr) data, (mp_size_t) count); goto done; } + + if (order == 1 && endian == -HOST_ENDIAN) + { + MPN_BSWAP_REVERSE (zp, (mp_srcptr) data, (mp_size_t) count); + goto done; + } } { |