| 1 |
! { dg-do run } |
| 2 |
! { dg-options "-ffrontend-optimize -fdump-tree-original" } |
| 3 |
! PR 37131 - check rank1/rank2 and rank2/rank1 cases for inline matmul. |
| 4 |
|
| 5 |
module foo |
| 6 |
implicit none |
| 7 |
contains |
| 8 |
subroutine a1b2(a,b,c) |
| 9 |
real, dimension(:), intent(in) :: a |
| 10 |
real, dimension(:,:), intent(in) :: b |
| 11 |
real, dimension(:), intent(out) :: c |
| 12 |
|
| 13 |
c = matmul(a,b) |
| 14 |
end subroutine a1b2 |
| 15 |
|
| 16 |
subroutine a2b1(a,b,c) |
| 17 |
real, dimension(:,:), intent(in) :: a |
| 18 |
real, dimension(:), intent(in) :: b |
| 19 |
real, dimension(:), intent(out) :: c |
| 20 |
|
| 21 |
c = matmul(a,b) |
| 22 |
end subroutine a2b1 |
| 23 |
end module foo |
| 24 |
|
| 25 |
program main |
| 26 |
use foo |
| 27 |
implicit none |
| 28 |
real, dimension(3) :: a1 |
| 29 |
real, dimension(3,2) :: b1 |
| 30 |
real, dimension(2) :: c1 |
| 31 |
|
| 32 |
real, dimension(3,2) :: a2 |
| 33 |
real, dimension(2) :: b2 |
| 34 |
real, dimension(3) :: c2 |
| 35 |
|
| 36 |
data a1 /17., -23., 29./ |
| 37 |
data b1 / 2., -3., 5., -7., 11., -13./ |
| 38 |
|
| 39 |
data b2/-2.,5./ |
| 40 |
|
| 41 |
a2 = -b1 |
| 42 |
call a1b2(a1,b1,c1) |
| 43 |
if (any(abs(c1 - (/248., -749./)) > 1e-3)) STOP 1 |
| 44 |
call a2b1(a2,b2,c2) |
| 45 |
if (any(abs(c2 - (/39., -61., 75./)) > 1e-3)) STOP 2 |
| 46 |
end program main |
| 47 |
|
| 48 |
! { dg-final { scan-tree-dump-times "_gfortran_matmul" 1 "original" } } |