summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/transpose_optimization_2.f90
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gfortran.dg/transpose_optimization_2.f90
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
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.
Diffstat (limited to 'gcc/testsuite/gfortran.dg/transpose_optimization_2.f90')
-rw-r--r--gcc/testsuite/gfortran.dg/transpose_optimization_2.f9066
1 files changed, 66 insertions, 0 deletions
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 <jvdelisle@gcc.gnu.org>
+!
+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" } }