]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Implement fast modulo reduction for nonbinary modular multiplication
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 5 Apr 2024 18:47:34 +0000 (20:47 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Fri, 21 Jun 2024 08:34:22 +0000 (10:34 +0200)
commit4e128544abc14871388ca194e61d6c482d3a11a6
tree1e40ee1db2526ca98aa7dc7ec9f32864816c8821
parent3cc00ccf4b8a866e2265445aa560a2ca00f613b8
ada: Implement fast modulo reduction for nonbinary modular multiplication

This implements modulo reduction for nonbinary modular multiplication with
small moduli by means of the standard division-free algorithm also used in
the optimizer, but with fewer constraints and therefore better results.

For the sake of consistency, it is also used for the 'Mod attribute of the
same modular types and, more generally, for the Mod (and Rem) operators of
unsigned types if the second operand is static and not a power of two.

gcc/ada/

* gcc-interface/gigi.h (fast_modulo_reduction): Declare.
* gcc-interface/trans.cc (gnat_to_gnu) <N_Op_Mod>: In the unsigned
case, call fast_modulo_reduction for {FLOOR,TRUNC}_MOD_EXPR if the
RHS is a constant and not a power of two, and the precision is not
larger than the word size.
* gcc-interface/utils2.cc: Include expmed.h.
(fast_modulo_reduction): New function.
(nonbinary_modular_operation): Call fast_modulo_reduction for the
multiplication if the precision is not larger than the word size.
gcc/ada/gcc-interface/gigi.h
gcc/ada/gcc-interface/trans.cc
gcc/ada/gcc-interface/utils2.cc