aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/inline_matmul_10.f90
blob: fe0d3ad10564f5048db0b2abc1316d0ee7ff325c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
! { dg-do  run }
! { dg-options "-ffrontend-optimize" }
! PR 66111 - this used to ICE with matmul inlining.
! Original test case by Mikael Morin.

implicit none
  integer, parameter :: n = 4
  integer, dimension(n, n) :: a, b, c
  integer, dimension(n*n)  :: p, res, res2
  integer, dimension(n)    :: v

  integer :: i

  p = [ +59, -53, +47, -43, &
        -37, +31, -29, +23, &
        +19, -17, +13, -11, &
        - 7, + 5, - 3, + 2  ]
  a = reshape(p, shape(a))
  b = reshape([(i, i=1, size(a))], shape(b))
  v = [ 3, 1, 2, 4]
  c = matmul(a, b)
  res = [ + 14, - 22, + 16, - 22, &
          +150, -158, +128, -138, &
          +286, -294, +240, -254, &
          +422, -430, +352, -370  ]
  !print *,c
  if (any(c /= reshape(res, shape(c)))) STOP 1
  c(:,v) = matmul(a, b)
  if (any(c(:,v) /= reshape(res, shape(c)))) STOP 2
  c(v,:) = matmul(a, b)
  if (any(c(v,:) /= reshape(res, shape(c)))) STOP 3

  c = matmul(a(:,v),b(v,:))
  if (any(c /= reshape(res, shape(c)))) STOP 4
end