aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorThomas Koenig <tkoenig@gcc.gnu.org>2011-03-21 07:14:42 +0000
committerThomas Koenig <tkoenig@gcc.gnu.org>2011-03-21 07:14:42 +0000
commit2757d5ecfc14883087e062b169e8355f8cc74b19 (patch)
treee7fa9989715e0c8733622fdf2e9e11eb709cdcb1 /gcc/testsuite
parent14a41392aab6bc963db2b4248b16aa2b5af09aa5 (diff)
downloadgcc-2757d5ecfc14883087e062b169e8355f8cc74b19.zip
gcc-2757d5ecfc14883087e062b169e8355f8cc74b19.tar.gz
gcc-2757d5ecfc14883087e062b169e8355f8cc74b19.tar.bz2
re PR fortran/22572 (Double occurrence of matmul intrinsic not optimised)
2010-03-21 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/22572 * gfortran.h (gfc_option_t) : Add flag_aggressive_function_elimination. (gfc_dep_compare_functions): Add prototype. * lang.opt: Add faggressive-function-elimination. * invoke.texi: Document -faggressive-function-elimination. * frontend_passes (expr_array): New static variable. (expr_size): Likewise. (expr_count): Likewise. (current_code): Likewise. (current_ns): Likewise. (gfc_run_passes): Allocate and free space for expressions. (cfe_register_funcs): New function. (create_var): New function. (cfc_expr_0): New function. (cfe_code): New function. (optimize_namespace): Invoke gfc_code_walker with cfe_code and cfe_expr_0. * dependency.c (gfc_dep_compare_functions): New function. (gfc_dep_compare_expr): Use it. * options.c (gfc_init_options): Handle flag_aggressive_function_elimination. (gfc_handle_option): Likewise. 2010-03-21 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/22572 * gfortran.dg/function_optimize_1.f90: New test. * gfortran.dg/function_optimize_2.f90: New test. From-SVN: r171207
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gfortran.dg/function_optimize_1.f9046
-rw-r--r--gcc/testsuite/gfortran.dg/function_optimize_2.f9047
3 files changed, 99 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 251ffe7..259bcc0 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2010-03-21 Thomas Koenig <tkoenig@gcc.gnu.org>
+
+ PR fortran/22572
+ * gfortran.dg/function_optimize_1.f90: New test.
+ * gfortran.dg/function_optimize_2.f90: New test.
+
2011-03-20 H.J. Lu <hongjiu.lu@intel.com>
PR rtl-optimization/47502
diff --git a/gcc/testsuite/gfortran.dg/function_optimize_1.f90 b/gcc/testsuite/gfortran.dg/function_optimize_1.f90
new file mode 100644
index 0000000..eaa915f
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/function_optimize_1.f90
@@ -0,0 +1,46 @@
+! { dg-do compile }
+! { dg-options "-O -fdump-tree-original" }
+program main
+ implicit none
+ real, dimension(2,2) :: a, b, c, d
+ integer :: i
+ real :: x, z
+ character(60) :: line
+ real, external :: ext_func
+ interface
+ elemental function element(x)
+ real, intent(in) :: x
+ real :: elem
+ end function element
+ pure function mypure(x)
+ real, intent(in) :: x
+ integer :: mypure
+ end function mypure
+ elemental impure function elem_impure(x)
+ real, intent(in) :: x
+ real :: elem_impure
+ end function elem_impure
+ end interface
+
+ data a /2., 3., 5., 7./
+ data b /11., 13., 17., 23./
+ write (unit=line, fmt='(4F7.2)') matmul(a,b) + matmul(a,b)
+ z = sin(x) + cos(x) + sin(x) + cos(x)
+ print *,z
+ x = ext_func(a) + 23 + ext_func(a)
+ print *,d,x
+ z = element(x) + element(x)
+ print *,z
+ i = mypure(x) - mypure(x)
+ print *,i
+ z = elem_impure(x) - elem_impure(x)
+ print *,z
+end program main
+! { dg-final { scan-tree-dump-times "matmul_r4" 1 "original" } }
+! { dg-final { scan-tree-dump-times "__builtin_sinf" 1 "original" } }
+! { dg-final { scan-tree-dump-times "__builtin_cosf" 1 "original" } }
+! { dg-final { scan-tree-dump-times "ext_func" 2 "original" } }
+! { dg-final { scan-tree-dump-times "element" 1 "original" } }
+! { dg-final { scan-tree-dump-times "mypure" 1 "original" } }
+! { dg-final { scan-tree-dump-times "elem_impure" 2 "original" } }
+! { dg-final { cleanup-tree-dump "original" } }
diff --git a/gcc/testsuite/gfortran.dg/function_optimize_2.f90 b/gcc/testsuite/gfortran.dg/function_optimize_2.f90
new file mode 100644
index 0000000..8105661
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/function_optimize_2.f90
@@ -0,0 +1,47 @@
+! { dg-do compile }
+! { dg-options "-O -faggressive-function-elimination -fdump-tree-original" }
+program main
+ implicit none
+ real, dimension(2,2) :: a, b, c, d
+ real :: x, z
+ integer :: i
+ character(60) :: line
+ real, external :: ext_func
+ interface
+ elemental function element(x)
+ real, intent(in) :: x
+ real :: elem
+ end function element
+ pure function mypure(x)
+ real, intent(in) :: x
+ integer :: mypure
+ end function mypure
+ elemental impure function elem_impure(x)
+ real, intent(in) :: x
+ real :: elem_impure
+ end function elem_impure
+ end interface
+
+ data a /2., 3., 5., 7./
+ data b /11., 13., 17., 23./
+ write (unit=line, fmt='(4F7.2)') matmul(a,b) + matmul(a,b)
+ x = 1.2
+ z = sin(x) + cos(x) + sin(x) + cos(x)
+ print *,z
+ x = ext_func(a) + 23 + ext_func(a)
+ print *,d,x
+ z = element(x) + element(x)
+ print *,z
+ i = mypure(x) - mypure(x)
+ print *,i
+ z = elem_impure(x) - elem_impure(x)
+ print *,z
+end program main
+! { dg-final { scan-tree-dump-times "matmul_r4" 1 "original" } }
+! { dg-final { scan-tree-dump-times "__builtin_sinf" 1 "original" } }
+! { dg-final { scan-tree-dump-times "__builtin_cosf" 1 "original" } }
+! { dg-final { scan-tree-dump-times "ext_func" 1 "original" } }
+! { dg-final { scan-tree-dump-times "element" 1 "original" } }
+! { dg-final { scan-tree-dump-times "mypure" 1 "original" } }
+! { dg-final { scan-tree-dump-times "elem_impure" 1 "original" } }
+! { dg-final { cleanup-tree-dump "original" } }