From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- .../gfortran.dg/transpose_optimization_2.f90 | 66 ++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/transpose_optimization_2.f90 (limited to 'gcc/testsuite/gfortran.dg/transpose_optimization_2.f90') diff --git a/gcc/testsuite/gfortran.dg/transpose_optimization_2.f90 b/gcc/testsuite/gfortran.dg/transpose_optimization_2.f90 new file mode 100644 index 000000000..ba0337407 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/transpose_optimization_2.f90 @@ -0,0 +1,66 @@ +! { dg-do run } +! { dg-options "-fdump-tree-original " } +! Checks the fix for PR46896, in which the optimization that passes +! the argument of TRANSPOSE directly missed the possible aliasing +! through host association. +! +! Contributed by Jerry DeLisle +! +module mod + integer :: b(2,3) = reshape([1,2,3,4,5,6], [2,3]) +contains + subroutine msub(x) + integer :: x(:,:) + b(1,:) = 99 + b(2,:) = x(:,1) + if (any (b(:,1) /= [99, 1]).or.any (b(:,2) /= [99, 3])) call abort() + end subroutine msub + subroutine pure_msub(x, y) + integer, intent(in) :: x(:,:) + integer, intent(OUT) :: y(size (x, 2), size (x, 1)) + y = transpose (x) + end subroutine pure_msub +end + + use mod + integer :: a(2,3) = reshape([1,2,3,4,5,6], [2,3]) + call impure + call purity +contains +! +! pure_sub and pure_msub could be PURE, if so declared. They do not +! need a temporary. +! + subroutine purity + integer :: c(2,3) + call pure_sub(transpose(a), c) + if (any (c .ne. a)) call abort + call pure_msub(transpose(b), c) + if (any (c .ne. b)) call abort + end subroutine purity +! +! sub and msub both need temporaries to avoid aliasing. +! + subroutine impure + call sub(transpose(a)) + end subroutine impure + + subroutine sub(x) + integer :: x(:,:) + a(1,:) = 88 + a(2,:) = x(:,1) + if (any (a(:,1) /= [88, 1]).or.any (a(:,2) /= [88, 3])) call abort() + end subroutine sub + subroutine pure_sub(x, y) + integer, intent(in) :: x(:,:) + integer, intent(OUT) :: y(size (x, 2), size (x, 1)) + y = transpose (x) + end subroutine pure_sub +end +! +! The check below for temporaries gave 14 and 33 for "parm" and "atmp". +! +! { dg-final { scan-tree-dump-times "parm" 66 "original" } } +! { dg-final { scan-tree-dump-times "atmp" 12 "original" } } +! { dg-final { cleanup-tree-dump "original" } } +! { dg-final { cleanup-modules "mod" } } -- cgit v1.2.3