aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorThomas Koenig <tkoenig@gcc.gnu.org>2013-04-30 21:45:13 +0000
committerThomas Koenig <tkoenig@gcc.gnu.org>2013-04-30 21:45:13 +0000
commit068b04fe4cd176294f6110c6dca28d24e65d6121 (patch)
treeefd1bbd12f3f9ffed58a0089a798e89c2ca28db9 /gcc/testsuite
parentdc4ea06f6aaf6d964b8ef74be45a9e79c2f1f805 (diff)
downloadgcc-068b04fe4cd176294f6110c6dca28d24e65d6121.zip
gcc-068b04fe4cd176294f6110c6dca28d24e65d6121.tar.gz
gcc-068b04fe4cd176294f6110c6dca28d24e65d6121.tar.bz2
re PR fortran/57071 (Optimize (-1)**k to 1 - 2 * mod(K, 2))
2013-04-30 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/57071 * frontend-passes.c (optimize_power): Simplify 1**k to 1. 2013-04-30 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/57071 * gfortran.dg/power_5.f90: New test. From-SVN: r198476
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/power_5.f9036
2 files changed, 41 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ae111b2..1016036 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2013-04-30 Thomas Koenig <tkoenig@gcc.gnu.org>
+
+ PR fortran/57071
+ * gfortran.dg/power_5.f90: New test.
+
2013-04-30 Richard Biener <rguenther@suse.de>
PR middle-end/57122
diff --git a/gcc/testsuite/gfortran.dg/power_5.f90 b/gcc/testsuite/gfortran.dg/power_5.f90
new file mode 100644
index 0000000..f42b260
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/power_5.f90
@@ -0,0 +1,36 @@
+! { dg-do run }
+! { dg-options "-ffrontend-optimize -fdump-tree-original" }
+! PR 57071 - Check that 1**k is transformed into 1
+program main
+ implicit none
+ integer, parameter :: n = 3
+ integer(kind=8), dimension(-n:n) :: a
+ integer, dimension(-n:n) :: c, d
+ integer :: m
+ integer :: i, v
+ integer (kind=2) :: i2
+
+ v = 1
+ m = n
+ ! Test in scalar expressions
+ do i=-n,n
+ if (v /= 1**i) call abort
+ end do
+
+ ! Test in array constructors
+ a(-m:m) = [ (1**i, i= -m, m) ]
+ if (any(a .ne. v)) call abort
+
+ ! Test in array expressions
+ c = [ ( i, i = -n , n ) ]
+ d = 1**c
+ if (any(d .ne. v)) call abort
+
+ ! Test in different kind expressions
+ do i2=-n,n
+ if (v /= 1**i2) call abort
+ end do
+
+end program main
+! { dg-final { scan-tree-dump-times "_gfortran_pow_i4_i4" 0 "original" } }
+! { dg-final { cleanup-tree-dump "original" } }