2017-02-20 Paul Thomas <pault@gcc.gnu.org>
[official-gcc.git] / gcc / testsuite / gfortran.dg / inline_matmul_3.f90
blob96e53dc4633fb6228b2f0a42432b732063d3bf5f
1 ! { dg-do run }
2 ! { dg-options "-O3 -finline-matmul-limit=2 -fdump-tree-optimized" }
3 ! PR 37131 - all calls to matmul should be kept
4 program main
5 real, dimension(3,2) :: a
6 real, dimension(2,4) :: b
7 real, dimension(3,4) :: c
8 real, dimension(3,4) :: cres
9 real, dimension(:,:), allocatable :: calloc
10 integer :: a1 = size(a,1), a2 = size(a,2)
11 integer :: b1 = size(b,1), b2 = size(b,2)
12 integer :: c1 = size(c,1), c2 = size(c,2)
14 data a / 2., -3., 5., -7., 11., -13./
15 data b /17., -23., 29., -31., 37., -39., 41., -47./
16 data cres /195., -304., 384., 275., -428., 548., 347., -540., 692., 411., -640., 816./
17 c = matmul(a,b)
18 if (sum(c-cres)>1e-4) call abort
20 calloc = matmul(a,b)
21 if (sum(calloc-cres)>1e-4) call abort
22 if (any([size(calloc,1), size(calloc,2)] /= [3,4])) call abort
23 deallocate(calloc)
25 allocate(calloc(4,4))
26 calloc = matmul(a,b)
27 if (sum(calloc-cres)>1e-4) call abort
28 if (any([size(calloc,1), size(calloc,2)] /= [3,4])) call abort
29 deallocate(calloc)
31 allocate(calloc(3,3))
32 calloc = matmul(a,b)
33 if (sum(calloc-cres)>1e-4) call abort
34 if (any([size(calloc,1), size(calloc,2)] /= [3,4])) call abort
35 deallocate(calloc)
37 block
38 real :: aa(a1, a2), bb(b1, b2), cc(c1, c2)
39 aa = a
40 bb = b
42 cc = matmul(aa,bb)
43 if (sum(cc-cres)>1e-4) call abort
44 calloc = matmul(aa,bb)
45 if (sum(calloc-cres)>1e-4) call abort
46 if (any([size(calloc,1), size(calloc,2)] /= [3,4])) call abort
47 calloc = 42.
48 deallocate(calloc)
50 allocate(calloc(4,4))
51 calloc = matmul(aa,bb)
52 if (sum(calloc-cres)>1e-4) call abort
53 if (any([size(calloc,1), size(calloc,2)] /= [3,4])) call abort
54 deallocate(calloc)
56 allocate(calloc(3,3))
57 calloc = matmul(aa,bb)
58 if (sum(calloc-cres)>1e-4) call abort
59 if (any([size(calloc,1), size(calloc,2)] /= [3,4])) call abort
60 deallocate(calloc)
61 end block
63 end program main
64 ! { dg-final { scan-tree-dump-times "_gfortran_matmul" 8 "optimized" } }