aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/i386/vect-pr82426.c
blob: 03b10adff9b6bad6dafac9210cf7fcbe8cefcbf4 (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
/* i?86 does not have V2SF, x32 does though.  */
/* { dg-do compile { target { ! ia32 } } } */
/* { dg-options "-O3 -mavx -mfma" } */

struct Matrix
{
  float m11;
  float m12;
  float m21;
  float m22;
  float dx;
  float dy;
};

struct Matrix multiply(const struct Matrix *a, const struct Matrix *b)
{
  struct Matrix out;
  out.m11 = a->m11*b->m11 + a->m12*b->m21;
  out.m12 = a->m11*b->m12 + a->m12*b->m22;
  out.m21 = a->m21*b->m11 + a->m22*b->m21;
  out.m22 = a->m21*b->m12 + a->m22*b->m22;

  out.dx = a->dx*b->m11  + a->dy*b->m21 + b->dx;
  out.dy = a->dx*b->m12  + a->dy*b->m22 + b->dy;
  return out;
}

/* The whole kernel should be vectorized with V4SF and V2SF operations.  */
/* { dg-final { scan-assembler-times "vadd" 1 } } */
/* { dg-final { scan-assembler-times "vmul" 2 } } */
/* { dg-final { scan-assembler-times "vfma" 2 } } */