]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Optimize 2**N to avoid explicit 'if' in modular case
authorBob Duff <duff@adacore.com>
Fri, 6 Jan 2023 18:23:36 +0000 (13:23 -0500)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 15 May 2023 09:36:41 +0000 (11:36 +0200)
commit4b7373ea32eb6c129cc9af660945409612861b07
tree9a20711b7fd6e5b7d2f121ffd01e5e21ddfaa443
parentb4509d1960165b205425c5b14ef1ff4ea5fd4435
ada: Optimize 2**N to avoid explicit 'if' in modular case

The compiler usually turns 2**N into Shift_Left(1,N).
This patch removes the check for "shift amount too big" in the
modular case, because Shift_Left works properly in that case
(i.e. if N is very large, it returns 0).

This removes a redundant check on most hardware; Shift_Left
takes care of large shirt amounts as necessary, even though
most hardware does not.

gcc/ada/

* exp_ch4.adb
(Expand_N_Op_Expon): Remove the too-big check. Simplify. Signed
and modular cases are combined, etc. Remove code with comment "We
only handle cases where the right type is a[sic] integer", because
the right operand must always be an integer at this point.
gcc/ada/exp_ch4.adb