libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / strlenopt-95.c
blob6e0a79d3e691fe2ad1a4cec195656134e471c2dd
1 /* Verify strlen results of vector assignments.
2 { dg-do compile }
3 { dg-options "-O2 -Wall -fdump-tree-optimized" } */
5 #include "strlenopt.h"
7 #define V(N) __attribute__ ((vector_size (N)))
9 typedef V (1) char VC1;
10 typedef V (2) char VC2;
11 typedef V (4) char VC4;
12 typedef V (8) char VC8;
13 typedef V (16) char VC16;
15 extern char a[];
17 #define A(expr) ((expr) ? (void)0 : abort ())
19 void test_fold (int i)
21 *(VC4*)a = (VC4){ };
22 A (strlen (a) == 0);
23 A (!a[1] && !a[2] && !a[3]);
25 *(VC4*)a = (VC4){ 0, 1 };
26 A (strlen (a) == 0);
27 A (a[1] == 1 && !a[2] && !a[3]);
29 *(VC4*)a = (VC4){ 1 };
30 A (strlen (a) == 1);
31 A (!a[1] && !a[2] && !a[3]);
33 *(VC4*)a = (VC4){ 1, 0, 3 };
34 A (strlen (a) == 1);
35 A (!a[1] && a[2] == 3 && !a[3]);
37 *(VC4*)a = (VC4){ 1, 2 };
38 A (strlen (a) == 2);
39 A (!a[2] && !a[3]);
41 *(VC4*)a = (VC4){ 1, 2, 0, 4 };
42 A (strlen (a) == 2);
43 A (!a[2] && a[3] == 4);
45 *(VC4*)a = (VC4){ 1, 2, 3 };
46 A (strlen (a) == 3);
47 A (!a[3]);
49 *(VC8*)a = (VC8){ 1, 2, 3, 0, 5 };
50 A (strlen (a) == 3);
52 *(VC8*)a = (VC8){ 1, 2, 3, 0, 5, 6 };
53 A (strlen (a) == 3);
55 *(VC8*)a = (VC8){ 1, 2, 3, 0, 5, 6, 7, 8 };
56 A (strlen (a) == 3);
57 A (strlen (a + 1) == 2);
58 A (strlen (a + 2) == 1);
59 A (strlen (a + 3) == 0);
61 A (a[4] == 5 && a[5] == 6 && a[6] == 7 && a[7] == 8);
64 /* { dg-final { scan-tree-dump-not "abort \\(" "optimized" } }
65 { dg-final { scan-tree-dump-not "strlen \\(" "optimized" } } */