aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/vect/vect-bitfield-write-5.c
blob: 386de504aad82c0ca7d05f80cf5c5f8380c79bc8 (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
36
37
38
39
40
41
42
43
44
45
/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */
/* { dg-require-effective-target vect_int } */

#include <stdarg.h>
#include "tree-vect.h"

extern void abort(void);

struct s {
    unsigned b : 23;
    unsigned a : 8;
};

#define N 32
#define V 5
struct s A[N];

void __attribute__ ((noipa))
f(struct s *ptr, unsigned n) {
    for (int i = 0; i < n; ++i)
      ptr[i].a = V;
}

void __attribute__ ((noipa))
check_f(struct s *ptr) {
#pragma GCC novector
    for (unsigned i = 0; i < N; ++i)
      if (ptr[i].a != V)
	abort ();
}

int main (void)
{
  check_vect ();
  __builtin_memset (&A[0], 0, sizeof(struct s) * N);

  f(&A[0], N);
  check_f (&A[0]);

  return 0;
}

/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */

/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */