This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gfortran,patch] Fix constant-integer exponentiation (PR31120)
- From: FX Coudert <fxcoudert at gmail dot com>
- To: "fortran at gcc dot gnu dot org List" <fortran at gcc dot gnu dot org>, gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 16 Mar 2007 00:03:15 +0100
- Subject: [gfortran,patch] Fix constant-integer exponentiation (PR31120)
Hi all,
Attached patch fixes code-generation for constant integer
exponentiation (PR31120). Actually, the code generation is fine, but
the way we handled the constant integer tree was wrong. The patch
makes us use the fit the constant into a HOST_WIDE_INT if possible
(as determined by the very useful double_int_to_shwi() function). If
not, we generate of function call, since the exponent will be huge
anyway, people are not really expected to write such code. Then, we
carefully take the absolute value so that the asymmetric integer
range is taken care of. Then, we use an unsigned HOST_WIDE_INT for
the rest of the work.
This simple patch fixes all issues reported in the PR, including the
memory explosion on MacOS. It comes with a mega-testcase with both
compile-time and runtime checks.
Bootstrapped and regtested on i686-linux, OK for mainline and 4.2?
FX
Attachment:
pr31120.ChangeLog
Description: Binary data
Attachment:
pr31120.diff
Description: Binary data