RISC-V: Fix "Nan-box the result of movbf on soft-bf16"
[official-gcc.git] / gcc / testsuite / gfortran.dg / inline_matmul_4.f90
blobcb4e05121ca38e61ee8669439174bd117d69bb40
1 ! { dg-do run }
2 ! { dg-options "-O3 -finline-matmul-limit=10 -fdump-tree-optimized -fdump-tree-original" }
3 ! PR 37131 - all calls to matmul should be optimized away with -O3
4 ! and the high limit.
5 program main
6 real, dimension(3,2) :: a
7 real, dimension(2,4) :: b
8 real, dimension(3,4) :: c
9 real, dimension(3,4) :: cres
10 real, dimension(:,:), allocatable :: calloc
11 integer :: a1 = size(a,1), a2 = size(a,2)
12 integer :: b1 = size(b,1), b2 = size(b,2)
13 integer :: c1 = size(c,1), c2 = size(c,2)
15 data a / 2., -3., 5., -7., 11., -13./
16 data b /17., -23., 29., -31., 37., -39., 41., -47./
17 data cres /195., -304., 384., 275., -428., 548., 347., -540., 692., 411., -640., 816./
18 c = matmul(a,b)
19 if (sum(c-cres)>1e-4) STOP 1
21 calloc = matmul(a,b)
22 if (sum(calloc-cres)>1e-4) STOP 2
23 if (any([size(calloc,1), size(calloc,2)] /= [3,4])) STOP 3
24 deallocate(calloc)
26 allocate(calloc(4,4))
27 calloc = matmul(a,b)
28 if (sum(calloc-cres)>1e-4) STOP 4
29 if (any([size(calloc,1), size(calloc,2)] /= [3,4])) STOP 5
30 deallocate(calloc)
32 allocate(calloc(3,3))
33 calloc = matmul(a,b)
34 if (sum(calloc-cres)>1e-4) STOP 6
35 if (any([size(calloc,1), size(calloc,2)] /= [3,4])) STOP 7
36 deallocate(calloc)
38 block
39 real :: aa(a1, a2), bb(b1, b2), cc(c1, c2)
40 aa = a
41 bb = b
43 cc = matmul(aa,bb)
44 if (sum(cc-cres)>1e-4) STOP 8
45 calloc = matmul(aa,bb)
46 if (sum(calloc-cres)>1e-4) STOP 9
47 if (any([size(calloc,1), size(calloc,2)] /= [3,4])) STOP 10
48 calloc = 42.
49 deallocate(calloc)
51 allocate(calloc(4,4))
52 calloc = matmul(aa,bb)
53 if (sum(calloc-cres)>1e-4) STOP 11
54 if (any([size(calloc,1), size(calloc,2)] /= [3,4])) STOP 12
55 deallocate(calloc)
57 allocate(calloc(3,3))
58 calloc = matmul(aa,bb)
59 if (sum(calloc-cres)>1e-4) STOP 13
60 if (any([size(calloc,1), size(calloc,2)] /= [3,4])) STOP 14
61 deallocate(calloc)
62 end block
64 end program main
65 ! { dg-final { scan-tree-dump-times "_gfortran_matmul" 4 "original" } }
66 ! { dg-final { scan-tree-dump-times "_gfortran_matmul" 0 "optimized" } }