This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]