This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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] | |
Dear all,
now that my copyright assignment is on file, here's my first attempt
at a non-trivial patch.
I have slightly rearranged Thomas' code, removed some, and added
generalizations for (2**e)**n and (-2**e)**n. It works with the
testcase below.
I'd like some feedback how to properly handle the case when
(-2**e) = -HUGE()-1, i.e. the number that falls outside the
symmetric range. Should one skip that one? Does anyone have
a template how to detect that case easily? Regtesting otherwise
would fail for the last test (which most likely should be removed
later).
Thanks,
Harald
P.S.: Changelogs will follow with the final submission.
! { dg-do run }
! { dg-additional-options "-fdump-tree-original" }
!
! PR88579 - Test optimizations for bases that are powers of 2 or -2.
program p
implicit none
integer(4) :: i, u
integer(8) :: v
u = 1
do i=1,5
u = u * 64_4
if (u /= 64_4 ** i) stop 1
end do
v = 1
do i=1,7
v = v * 256_8
if (v /= 256_8 ** i) stop 2
end do
v = 1
do i=1,3
v = v * 65536_8
if (v /= 65536_8 ** i) stop 3
end do
v = 1
do i=1,7
v = v * (-256_8)
if (v /= (-256_8) ** i) stop 4
end do
u = 1
do i=1,1
u = u * (-HUGE(1_4)-1)
if (u /= (-HUGE(1_4)-1) ** i) stop 5
end do
end program p
! { dg-final { scan-tree-dump-not "_gfortran_pow" "original" } }
Attachment:
pr88579.patch-v0
Description: Text document
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |