]>
git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gcc.dg/strlenopt-83.c
1 /* PR tree-optimization/83821 - local aggregate initialization defeats
4 { dg-options "-O2 -Wall -fdump-tree-optimized" }
5 { dg-require-effective-target alloca } */
8 char *p_p2
, *p_p5
, *p_p9
, *p_p14
;
10 unsigned n0
, n1
, n2
, n3
, n4
;
13 static inline __attribute__ ((always_inline
)) void
14 elim_strlen_of_consecutive_strcpy (char *p
)
17 __builtin_strcpy (p_p2
, "12");
20 __builtin_strcpy (p_p5
, "124");
23 __builtin_strcpy (p_p9
, "1245");
27 n0
= __builtin_strlen (p
);
28 n1
= __builtin_strlen (p_p2
);
29 n2
= __builtin_strlen (p_p5
);
30 n3
= __builtin_strlen (p_p9
);
32 /* The following isn't handled yet:
33 n4 = __builtin_strlen (p_p14); */
35 if (n0
|| n1
!= 2 || n2
!= 3 || n3
!= 4)
40 void elim_strlen_of_consecutive_strcpy_in_alloca (unsigned n
)
42 /* Only known sizes are handled so far. */
45 char *p
= __builtin_alloca (n
);
49 elim_strlen_of_consecutive_strcpy (p
);
53 void elim_strlen_of_consecutive_strcpy_in_vla (unsigned n
)
55 /* Only known sizes are handled so far. */
62 elim_strlen_of_consecutive_strcpy (vla
);
65 void elim_strlen_of_consecutive_strcpy_in_malloc (unsigned n
)
67 char *p
= __builtin_malloc (n
);
71 elim_strlen_of_consecutive_strcpy (p
);
75 void elim_strlen_of_consecutive_strcpy_in_calloc (unsigned n
)
77 char *p
= __builtin_calloc (n
, 1);
79 /* Do not store into *P to verify that strlen knows it's zero. */
81 elim_strlen_of_consecutive_strcpy (p
);
84 /* { dg-final { scan-tree-dump-not "abort" "optimized" } } */