libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-bitfield-read-5.c
blob662aed104cf6078fd8cd9c5987c4a0d7c5ea3eb4
1 /* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */
2 /* { dg-require-effective-target vect_int } */
3 /* { dg-require-effective-target vect_shift } */
5 #include <stdarg.h>
6 #include "tree-vect.h"
8 extern void abort(void);
10 struct s {
11 unsigned a : 23; unsigned b : 9;
14 #define N 32
15 #define ELT0 {0x7FFFFFUL, 0}
16 #define ELT1 {0x7FFFFFUL, 1}
17 #define ELT2 {0x7FFFFFUL, 2}
18 #define ELT3 {0x7FFFFFUL, 3}
19 #define RES 48
20 struct s A[N]
21 = { ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3,
22 ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3,
23 ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3,
24 ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3};
26 int __attribute__ ((noipa))
27 f(struct s *ptr, unsigned n) {
28 int res = 0;
29 for (int i = 0; i < n; ++i)
30 res += ptr[i].b;
31 return res;
34 int main (void)
36 check_vect ();
38 if (f(&A[0], N) != RES)
39 abort ();
41 return 0;
44 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
45 /* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */