2 ! { dg-options "-Warray-temporaries -fdump-tree-original" }
5 ! Non-copying descriptor transpose optimization (for function call args).
7 ! Contributed by Richard Sandiford <richard@codesourcery.com>
11 subroutine ext1 (a
, b
)
12 real, intent (in
), dimension (:, :) :: a
, b
14 subroutine ext2 (a
, b
)
15 real, intent (in
), dimension (:, :) :: a
16 real, intent (out
), dimension (:, :) :: b
18 subroutine ext3 (a
, b
)
19 real, dimension (:, :) :: a
, b
23 ! No temporary needed here.
24 subroutine test1 (n
, a
, b
, c
)
26 real, dimension (n
, n
) :: a
, b
, c
27 a
= matmul (transpose (b
), c
)
30 ! No temporary either, as we know the arguments to matmul are intent(in)
31 subroutine test2 (n
, a
, b
)
33 real, dimension (n
, n
) :: a
, b
34 a
= matmul (transpose (b
), b
)
37 ! No temporary needed.
38 subroutine test3 (n
, a
, b
, c
)
40 real, dimension (n
, n
) :: a
, c
41 real, dimension (n
+4, n
+4) :: b
42 a
= matmul (transpose (b (2:n
+1, 3:n
+2)), c
)
45 ! A temporary is needed for the result of either the transpose or matmul.
46 subroutine test4 (n
, a
, b
)
48 real, dimension (n
, n
) :: a
, b
49 a
= matmul (transpose (a
), b
) ! { dg-warning "Creating array temporary" }
52 ! The temporary is needed here since the second argument to imp1
54 subroutine test5 (n
, a
)
56 real, dimension (n
, n
) :: a
57 call imp1 (transpose (a
), a
) ! { dg-warning "Creating array temporary" }
60 ! No temporaries are needed here; imp1 can't modify either argument.
61 ! We have to pack the arguments, however.
62 subroutine test6 (n
, a
, b
)
64 real, dimension (n
, n
) :: a
, b
65 call imp1 (transpose (a
), transpose (b
)) ! { dg-warning "Creating array temporary" }
68 ! No temporaries are needed here; imp1 can't modify either argument.
69 ! We don't have to pack the arguments.
70 subroutine test6_bis (n
, a
, b
)
72 real, dimension (n
, n
) :: a
, b
73 call ext3 (transpose (a
), transpose (b
))
74 end subroutine test6_bis
76 ! No temporary is neede here; the second argument is intent(in).
77 subroutine test7 (n
, a
)
79 real, dimension (n
, n
) :: a
80 call ext1 (transpose (a
), a
)
83 ! The temporary is needed here though.
84 subroutine test8 (n
, a
)
86 real, dimension (n
, n
) :: a
87 call ext2 (transpose (a
), a
) ! { dg-warning "Creating array temporary" }
90 ! Silly, but we don't need any temporaries here.
91 subroutine test9 (n
, a
)
93 real, dimension (n
, n
) :: a
94 call ext1 (transpose (transpose (a
)), a
)
97 ! The outer transpose needs a temporary; the inner one doesn't.
98 subroutine test10 (n
, a
)
100 real, dimension (n
, n
) :: a
101 call ext2 (transpose (transpose (a
)), a
) ! { dg-warning "Creating array temporary" }
102 end subroutine test10
105 ! { dg-final { scan-tree-dump-times "struct\[^\\n\]*atmp" 4 "original" } }