Bounds-checking for Fortran testsuite was: Re: [gfortran, testsuite] Fix bounds checking for substrings, enable bounds chekcing in dg testsuite, assorted fixes
Tobias Schlüter
tobias.schlueter@physik.uni-muenchen.de
Tue Dec 12 20:33:00 GMT 2006
[ Sorry, I hit send to early before ]
Dorit Nuzman <DORIT@il.ibm.com> wrote on Tue, 12 Dec 2006:
> The vect testsuite is supposed to exercise all the different features of
> the vectorizer, but surely we could use more testing (especially if it's
> loop intensive code).
Ok, this is my candidate for a final patch which incorporates the
logic from vect.exp to determine on which targets it makes sense to
exercise -ftree-vectorize. Janis, can you look over the changes to
the testsuite framework, please. The change to the Fortran FE has
already been ok'ed by FX.
With this patch gfortran passes the testsuite with no unexpected
failures on i386-darwin, provided my workaround for PR 29516 is in
place.
- Tobi
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
-------------- next part --------------
2006-11-25 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
fortran/
* trans-expr (gfc_conv_substring): Check for empty substring.
testsuite/
* lib/fortran-torture.exp: Update copyright years. Remove
obsolete comment. Test -ftree-vectorize where it makes sense.
* lib/gfortran-dg.exp: Update copyright years. Use settings
from fortran-torture.exp.
* gfortran.dg/char_transpose_1.f90,
gfortran.dg/char_spread_1.f90, gfortran.dg/g77/dnrm2.f,
gfortran.dg/dependent_decls_1.f90: Fixout-of-bound errors.
* gfortran.dg/enum_10.f90, gfortran.dg/mixed_io_1.f90: Add
'-w' to dg-options.
Index: gcc/fortran/trans-expr.c
===================================================================
--- gcc/fortran/trans-expr.c (revision 119791)
+++ gcc/fortran/trans-expr.c (working copy)
@@ -278,9 +278,14 @@ gfc_conv_substring (gfc_se * se, gfc_ref
}
if (flag_bounds_check)
{
+ tree nonempty = fold_build2 (LE_EXPR, boolean_type_node,
+ start.expr, end.expr);
+
/* Check lower bound. */
fault = fold_build2 (LT_EXPR, boolean_type_node, start.expr,
build_int_cst (gfc_charlen_type_node, 1));
+ fault = fold_build2 (TRUTH_ANDIF_EXPR, boolean_type_node,
+ nonempty, fault);
if (name)
asprintf (&msg, "Substring out of bounds: lower bound of '%s' "
"is less than one", name);
@@ -293,6 +298,8 @@ gfc_conv_substring (gfc_se * se, gfc_ref
/* Check upper bound. */
fault = fold_build2 (GT_EXPR, boolean_type_node, end.expr,
se->string_length);
+ fault = fold_build2 (TRUTH_ANDIF_EXPR, boolean_type_node,
+ nonempty, fault);
if (name)
asprintf (&msg, "Substring out of bounds: upper bound of '%s' "
"exceeds string length", name);
Index: gcc/testsuite/lib/gfortran-dg.exp
===================================================================
--- gcc/testsuite/lib/gfortran-dg.exp (revision 119791)
+++ gcc/testsuite/lib/gfortran-dg.exp (working copy)
@@ -1,4 +1,4 @@
-# Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+# Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -14,6 +14,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+load_lib fortran-torture.exp
load_lib gcc-dg.exp
# Define gfortran callbacks for dg.exp.
Index: gcc/testsuite/lib/fortran-torture.exp
===================================================================
--- gcc/testsuite/lib/fortran-torture.exp (revision 119791)
+++ gcc/testsuite/lib/fortran-torture.exp (working copy)
@@ -1,4 +1,4 @@
-# Copyright (C) 2003 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2006 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -20,24 +20,54 @@
# This file was written by Steven Bosscher (s.bosscher@student.tudelft.nl)
# based on f-torture.exp, which was written by Rob Savoye.
-# The biggest change from g77 is that we always test all testcases with
-# loop options, because it is much harder to figure out whether a testcase
-# has loops if you have array syntax, like Fortran 95. In fact, the whole
-# point of F95 is arrays, so loops show up in most testcases anyway.
-
# The default option list can be overridden by
# TORTURE_OPTIONS="{ { list1 } ... { listN } }"
if ![info exists TORTURE_OPTIONS] {
+ # determine if host supports vectorization, and the necessary set
+ # of options, based on code from testsuite/vect/vect.exp
+
+ set vectorizer_options [list "-O2" "-ftree-vectorize"]
+
+ if { [istarget "powerpc*-*-*"]
+ && [is-effective-target powerpc_altivec_ok]
+ && [check_vmx_hw_available] } {
+ lappend vectorizer_options "-maltivec"
+ set test_tree_vectorize 1
+ } elseif { [istarget "spu-*-*"] } {
+ set test_tree_vectorize 1
+ } elseif { [istarget "i?86-*-*"] || [istarget "x86_64-*-*"] } {
+ lappend vectorizer_options "-msse2"
+ set test_tree_vectorize 1
+ } elseif { [istarget "mipsisa64*-*-*"]
+ && [check_effective_target_mpaired_single] } {
+ lappend vectorizer_options "-mpaired-single"
+ set test_tree_vectorize 1
+ } elseif [istarget "sparc*-*-*"] {
+ lappend vectorizer_options "-mcpu=ultrasparc" "-mvis"
+ set test_tree_vectorize 1
+ } elseif { [istarget "alpha*-*-*"]
+ && [check_alpha_max_hw_available] } {
+ lappend vectorizer_options "-mmax"
+ set test_tree_vectorize 1
+ } elseif [istarget "ia64-*-*"] {
+ set test_tree_vectorize 1
+ } else {
+ set test_tree_vectorize 0
+ }
+
set TORTURE_OPTIONS [list \
{ -O0 } { -O1 } { -O2 } \
{ -O2 -fomit-frame-pointer -finline-functions } \
{ -O2 -fomit-frame-pointer -finline-functions -funroll-loops } \
{ -O2 -fbounds-check } \
- { -O2 -fno-repack-arrays } \
{ -O3 -g } \
{ -Os }]
+
+ if { $test_tree_vectorize } {
+ lappend TORTURE_OPTIONS $vectorizer_options
+ }
}
Index: gcc/testsuite/gfortran.dg/char_transpose_1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/char_transpose_1.f90 (revision 119791)
+++ gcc/testsuite/gfortran.dg/char_transpose_1.f90 (working copy)
@@ -8,7 +8,7 @@ program main
do i2 = 1, n2
do i1 = 1, n1
- a (i1, i2) = 'ab'(i1:i1) // 'cde'(i2:i2) // 'cantrip'
+ a (i1, i2) = 'abc'(i1:i1) // 'defg'(i2:i2) // 'cantrip'
end do
end do
Index: gcc/testsuite/gfortran.dg/g77/dnrm2.f
===================================================================
--- gcc/testsuite/gfortran.dg/g77/dnrm2.f (revision 119791)
+++ gcc/testsuite/gfortran.dg/g77/dnrm2.f (working copy)
@@ -1,4 +1,5 @@
c { dg-do run }
+c { dg-options "-fno-bounds-check" }
CCC g77 0.5.21 `Actual Bugs':
CCC * A code-generation bug afflicts Intel x86 targets when `-O2' is
CCC specified compiling, for example, an old version of the `DNRM2'
Index: gcc/testsuite/gfortran.dg/char_spread_1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/char_spread_1.f90 (revision 119791)
+++ gcc/testsuite/gfortran.dg/char_spread_1.f90 (working copy)
@@ -8,7 +8,7 @@ program main
do i3 = 1, n3
do i1 = 1, n1
- a (i1, i3) = 'ab'(i1:i1) // 'cde'(i3:i3) // 'cantrip'
+ a (i1, i3) = 'abc'(i1:i1) // 'defg'(i3:i3) // 'cantrip'
end do
end do
Index: gcc/testsuite/gfortran.dg/enum_10.f90
===================================================================
--- gcc/testsuite/gfortran.dg/enum_10.f90 (revision 119791)
+++ gcc/testsuite/gfortran.dg/enum_10.f90 (working copy)
@@ -1,6 +1,6 @@
! { dg-do run }
! { dg-additional-sources enum_10.c }
-! { dg-options "-fshort-enums" }
+! { dg-options "-fshort-enums -w" }
! Make sure short enums are indeed interoperable with the
! corresponding C type.
Index: gcc/testsuite/gfortran.dg/mixed_io_1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/mixed_io_1.f90 (revision 119791)
+++ gcc/testsuite/gfortran.dg/mixed_io_1.f90 (working copy)
@@ -1,5 +1,6 @@
! { dg-do run }
! { dg-additional-sources mixed_io_1.c }
+! { dg-options "-w" }
call cio
write(*,"(A)") '6789' ! { dg-output "123456789" }
end
Index: gcc/testsuite/gfortran.dg/dependent_decls_1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/dependent_decls_1.f90 (revision 119791)
+++ gcc/testsuite/gfortran.dg/dependent_decls_1.f90 (working copy)
@@ -14,26 +14,26 @@ contains
subroutine foo1 (xmin)
real, intent(inout) :: xmin(:)
real :: x(size(xmin)+1) ! The declaration for r would be added
- real :: r(size(x)-2) ! to the function before that of x
+ real :: r(size(x)-1) ! to the function before that of x
xmin = r
- if (size(r) .ne. 9) call abort ()
+ if (size(r) .ne. 10) call abort ()
if (size(x) .ne. 11) call abort ()
end subroutine foo1
subroutine foo2 (xmin) ! This version was OK because of the
real, intent(inout) :: xmin(:) ! renaming of r which pushed it up
real :: x(size(xmin)+3) ! the symtree.
- real :: zr(size(x)-6)
+ real :: zr(size(x)-3)
xmin = zr
- if (size(zr) .ne. 7) call abort ()
+ if (size(zr) .ne. 10) call abort ()
if (size(x) .ne. 13) call abort ()
end subroutine foo2
subroutine foo3 (xmin)
real, intent(inout) :: xmin(:)
character(size(x)+2) :: y ! host associated x
character(len(y)+3) :: z ! This did not work for any combination
- real :: r(len(z)-10) ! of names.
+ real :: r(len(z)-5) ! of names.
xmin = r
- if (size(r) .ne. 5) call abort ()
+ if (size(r) .ne. 10) call abort ()
if (len(z) .ne. 15) call abort ()
end subroutine foo3
end program bar
More information about the Fortran
mailing list