111
|
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)
|
|
13
|
|
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)
|
131
|
18 if (sum(c-cres)>1e-4) STOP 1
|
111
|
19
|
|
20 calloc = matmul(a,b)
|
131
|
21 if (sum(calloc-cres)>1e-4) STOP 2
|
|
22 if (any([size(calloc,1), size(calloc,2)] /= [3,4])) STOP 3
|
111
|
23 deallocate(calloc)
|
|
24
|
|
25 allocate(calloc(4,4))
|
|
26 calloc = matmul(a,b)
|
131
|
27 if (sum(calloc-cres)>1e-4) STOP 4
|
|
28 if (any([size(calloc,1), size(calloc,2)] /= [3,4])) STOP 5
|
111
|
29 deallocate(calloc)
|
|
30
|
|
31 allocate(calloc(3,3))
|
|
32 calloc = matmul(a,b)
|
131
|
33 if (sum(calloc-cres)>1e-4) STOP 6
|
|
34 if (any([size(calloc,1), size(calloc,2)] /= [3,4])) STOP 7
|
111
|
35 deallocate(calloc)
|
|
36
|
|
37 block
|
|
38 real :: aa(a1, a2), bb(b1, b2), cc(c1, c2)
|
|
39 aa = a
|
|
40 bb = b
|
|
41
|
|
42 cc = matmul(aa,bb)
|
131
|
43 if (sum(cc-cres)>1e-4) STOP 8
|
111
|
44 calloc = matmul(aa,bb)
|
131
|
45 if (sum(calloc-cres)>1e-4) STOP 9
|
|
46 if (any([size(calloc,1), size(calloc,2)] /= [3,4])) STOP 10
|
111
|
47 calloc = 42.
|
|
48 deallocate(calloc)
|
|
49
|
|
50 allocate(calloc(4,4))
|
|
51 calloc = matmul(aa,bb)
|
131
|
52 if (sum(calloc-cres)>1e-4) STOP 11
|
|
53 if (any([size(calloc,1), size(calloc,2)] /= [3,4])) STOP 12
|
111
|
54 deallocate(calloc)
|
|
55
|
|
56 allocate(calloc(3,3))
|
|
57 calloc = matmul(aa,bb)
|
131
|
58 if (sum(calloc-cres)>1e-4) STOP 13
|
|
59 if (any([size(calloc,1), size(calloc,2)] /= [3,4])) STOP 14
|
111
|
60 deallocate(calloc)
|
|
61 end block
|
|
62
|
|
63 end program main
|
|
64 ! { dg-final { scan-tree-dump-times "_gfortran_matmul" 8 "optimized" } }
|