Commit Graph

1296 Commits

Author SHA1 Message Date
nijtmans
1cc289d215 better use of mp_isneg() and mp_iszero() 2019-11-11 21:52:20 +01:00
Steffen Jaeckel
0bc5c3292d
Merge pull request #450 from libtom/sqr-opt
make mp_sqr and mp_div_3 internal and add optimizations
2019-11-10 15:30:57 +01:00
Daniel Mendler
53becf6569
regen files 2019-11-09 06:43:59 +01:00
Daniel Mendler
6777baaf97
add macro MP_IS_2EXPT 2019-11-09 06:43:59 +01:00
Daniel Mendler
2e88b571c1
optimize mp_mul_d 2019-11-09 06:43:59 +01:00
Daniel Mendler
6ec36e0b9b
optimize mp_div_d 2019-11-09 06:43:59 +01:00
Daniel Mendler
4f00e75b8f
make mp_div_3 private 2019-11-09 06:43:58 +01:00
Daniel Mendler
0fa802f24b
make mp_sqr private (optimization of mp_mul) 2019-11-09 06:43:58 +01:00
Steffen Jaeckel
4077293f4a
Merge pull request #451 from libtom/simplify-mod
simplify mod functions
2019-11-07 21:12:56 +01:00
Daniel Mendler
61ebe7c047
simplify mod functions 2019-11-07 01:01:19 +01:00
Steffen Jaeckel
cc77fadb85
Merge pull request #444 from minad/lto
add COMPILE_LTO to test link time optimization
2019-11-05 23:11:36 +01:00
Steffen Jaeckel
67e1816822
Merge pull request #445 from libtom/fix-def-gen
fix generate_def, rename some internal files
2019-11-05 23:10:40 +01:00
Daniel Mendler
91d88ce3db
fix generate_def, rename some internal files 2019-11-05 21:11:58 +01:00
Daniel Mendler
3b98e82627
disable lto test for clang for now
it works on debian but not on the outdated travis ubuntu
2019-11-05 21:01:54 +01:00
Daniel Mendler
53a689d084
travis: install llvm-7 2019-11-05 20:29:59 +01:00
Daniel Mendler
74d828d526
don't use ranlib, ar s is equivalent 2019-11-05 20:28:59 +01:00
Daniel Mendler
e8e65119d1
add COMPILE_LTO to test link time optimization
the library performs best with lto since many small functions
can be inlined across objects.
2019-11-05 20:28:59 +01:00
Steffen Jaeckel
c893d217aa
Merge pull request #439 from libtom/radix-code-cleanup
mp_radix off-by-one error and other related code-cleanup
2019-11-05 20:16:01 +01:00
nijtmans
bbb178089d
mp_radix off-by-one error and other related code-cleanup 2019-11-05 20:15:24 +01:00
Steffen Jaeckel
7e47ae6550
Merge pull request #443 from libtom/rename-maxfast
rename MP_MAXFAST to MP_MAX_COMBA
2019-11-05 20:09:43 +01:00
Daniel Mendler
93f8e7603d
rename MP_MAXFAST to MP_MAX_COMBA 2019-11-05 20:09:23 +01:00
Steffen Jaeckel
b4c42576d7
Merge pull request #436 from fperrad/20191029_lint
some linting
2019-11-05 19:40:30 +01:00
Francois Perrad
40342807dc explicit operator precedence 2019-11-05 18:45:48 +01:00
Francois Perrad
146becbd9a literal suffix 2019-11-05 18:43:37 +01:00
Steffen Jaeckel
3035e22fd3
Merge pull request #434 from libtom/simplifications
Simplifications
2019-11-05 17:55:04 +01:00
Steffen Jaeckel
80176de372 re-enable checks for memcpy&memset
[skip ci]
2019-11-05 17:53:08 +01:00
Daniel Mendler
410bf49385
apply a series of simplifications
* this is the final commit of a series of simplifications,
  containing only the regenerated files and the explanation in the
  commit message

* This is in preparation of the size_t change/a potential representation change to use
  full width as in tfm, if a (partial?) merge with tfm is desired.
  These changes have their own merits however.

* Remove obfuscating tmpx digit pointers (fewer variables, it is more obvious what is
  being manipulated)

* Reduce scope of variables where possible

* Stricter error handling/checking (for example handling in karatsuba
  was broken)

* In some cases the result was written even in the case of an error
  (e.g. s_mp_is_divisible). This will hide bugs, since the user should
  check the return value (enforced by MP_WUR). Furthermore if the user
  accesses the non-initialized result, valgrind will complain for
  example. Global static analysis like coverity will also detect the issue.
  Therefore this improves the status quo.

* Introduce generic, private MP_EXCH macro which can be used to swap values.

* Introduce s_mp_copy_digs/s_mp_zero_digs/s_mp_zero_buf

* Some control flow simplifications, e.g, loops instead of goto

* Renamings of variables/labels for consistency

* Renamings of mul/sqr functions for more consistency, e.g., comba
  instead of fast suffix

* I didn't read through some very complex functions.
  They are so complex, I am too afraid and lazy to touch them.
  Maybe someone resposible wants to simplify them if possible. Hint... Hint...
  - mp_prime_strong_lucas_selfridge.c
  - s_mp_exptmod.c
  - s_mp_exptmod_fast.c
2019-11-04 15:41:33 +01:00
Daniel Mendler
5c335f8407
rename mul/sqr functions for consistency, comba instead of fast suffix 2019-11-04 15:41:33 +01:00
Daniel Mendler
3b710fbd7e
simplify mp_complement 2019-11-04 15:41:33 +01:00
Daniel Mendler
bcda8fc696
simplifications: remove unnecessary optimization
* these double checks are not necessary
* the compiler will move the early return outside of the called
  function, basically the functions is partially inlined
* however lto/amalgamation needed for the optimization
2019-11-04 15:41:33 +01:00
Daniel Mendler
795cd2013f
simplifications: add s_mp_zero_(digs|buf) and s_mp_copy_digs
Originally I made those as macros. However we have many
other small functions like mp_clamp, mp_exch which are also not implemented
as macros right now.

If we would use c99, I would implement them as private static inline
functions. And mp_exch would be a public static inline function.

But since we are bound to c89, we simply use normal functions.
To achieve optimal performance one should either use link time
optimization or amalgamation.
2019-11-04 15:41:32 +01:00
Daniel Mendler
b1f9bff192
simplifications: invmod 2019-11-04 15:41:32 +01:00
Daniel Mendler
56144eed1e
simplifications: reduce functions 2019-11-04 15:41:32 +01:00
Daniel Mendler
448f35e2e1
simplifications: prime functions 2019-11-04 15:41:32 +01:00
Daniel Mendler
8ac493512c
simplifications: mul/sqr comba 2019-11-04 15:41:32 +01:00
Daniel Mendler
7b6c6965bb
simplifications: toom and karatsuba 2019-11-04 15:41:32 +01:00
Daniel Mendler
143e0376a1
simplifications: basic arithmetic functions 2019-11-04 15:41:31 +01:00
Daniel Mendler
e60149dec7
simplifications: replace mp_mod_d by macro 2019-11-04 15:41:31 +01:00
Steffen Jaeckel
2d3262af26
Merge pull request #442 from libtom/bug-min-prec
MP_MIN_PREC too small, test with MP_PREC=MP_MIN_PREC
2019-11-04 14:06:19 +01:00
Daniel Mendler
2bbdbd0651
MP_MIN_PREC>=3 is needed for s_mp_div_school
test with MP_PREC=MP_MIN_PREC
2019-11-03 17:23:59 +01:00
Steffen Jaeckel
820f4bb060
Merge pull request #435 from libtom/simple-simplifications
first batch of simplifications
2019-10-29 21:27:01 +01:00
Daniel Mendler
3cdcec43e6
first batch of simplifications 2019-10-29 19:30:23 +01:00
Daniel Mendler
b9977adfb8
use uint8_t instead of unsigned char 2019-10-29 17:40:59 +01:00
Steffen Jaeckel
98753c6718
Merge pull request #432 from libtom/no-deprecated-pragma
introduce MP_NO_DEPRECATED_PRAGMA
2019-10-29 17:20:40 +01:00
Steffen Jaeckel
af376edcde no more MP_WUR in timing.c 2019-10-29 16:37:56 +01:00
Steffen Jaeckel
8456782cc5 don't allow disabling of WUR checks 2019-10-29 15:40:47 +01:00
Steffen Jaeckel
57fbf5a880 also build support/ branches in CI
(cherry picked from commit 783ffb82dd5ddddce3d3bbd88661bcda44162458)
2019-10-29 15:39:00 +01:00
Steffen Jaeckel
e95dd24e4f introduce MP_NO_DEPRECATED_PRAGMA 2019-10-29 15:39:00 +01:00
Steffen Jaeckel
57ccd9f0c3
Merge pull request #431 from libtom/rework-tests
clean-up test.c
2019-10-29 15:38:31 +01:00
Steffen Jaeckel
4500d066c1 also no MP_WUR in mtest_opponent() 2019-10-29 14:41:33 +01:00