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