2 ! { dg-options "-ffrontend-optimize -fdump-tree-optimized -Wrealloc-lhs -finline-matmul-limit=1000 -O" }
3 ! PR 66094: Check functionality for MATMUL(TRANSPOSE(A),B)) for two-dimensional arrays
6 integer, parameter :: n
= 3, m
=4, cnt
=2
7 real, dimension(cnt
,n
) :: a
8 real, dimension(cnt
,m
) :: b
9 real, dimension(n
,m
) :: c
, cres
10 real, dimension(:,:), allocatable
:: calloc
11 integer :: in
, im
, icnt
13 data a
/ 2., -3., 5., -7., 11., -13./
14 data b
/17., -23., 29., -31., 37., -39., 41., -47./
15 data cres
/103., 246., 486., 151., 362., 722., &
16 191., 458., 914., 223., 534., 1062./
18 c
= matmul(transpose(a
),b
)
19 if (sum(c
-cres
)>1e-4) call abort
20 if (sum(c
-cres
)>1e-4) call abort
23 calloc
= matmul(transpose(a
),b
) ! { dg-warning "Code for reallocating the allocatable array" }
24 if (any(shape(c
) /= shape(calloc
))) call abort
25 if (sum(calloc
-cres
)>1e-4) call abort
28 ! Allocated to wrong shape
29 allocate (calloc(10,10))
30 calloc
= matmul(transpose(a
),b
) ! { dg-warning "Code for reallocating the allocatable array" }
31 if (any(shape(c
) /= shape(calloc
))) call abort
32 if (sum(calloc
-cres
)>1e-4) call abort
35 ! cycle through a few test cases...
40 real, dimension(icnt
,in
) :: a2
41 real, dimension(icnt
,im
) :: b2
42 real, dimension(in
,im
) :: c2
,cr
44 call random_number(a2
)
45 call random_number(b2
)
50 c2(i
,j
) = c2(i
,j
) + a2(k
,i
) * b2(k
,j
)
54 cr
= matmul(transpose(a2
), b2
)
55 if (any(abs(c2
-cr
) > 1e-4)) call abort
61 ! { dg-final { scan-tree-dump-times "_gfortran_matmul" 0 "optimized" } }