[gfortran,patch] Fix constant-integer exponentiation (PR31120)

FX Coudert fxcoudert@gmail.com
Thu Mar 15 23:36:00 GMT 2007


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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr31120.ChangeLog
Type: application/octet-stream
Size: 382 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20070315/fc1beeee/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr31120.diff
Type: application/octet-stream
Size: 8252 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20070315/fc1beeee/attachment-0001.obj>


More information about the Gcc-patches mailing list