Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/gcc.dg/strcmpopt_2.c @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | |
children | 1830386684a0 |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 131:84e7813d76e9 |
---|---|
1 /* { dg-do run } */ | |
2 /* { dg-options "-O2 -fdump-tree-strlen" } */ | |
3 | |
4 char s[100] = {'a','b','c','d'}; | |
5 typedef struct { char s[8]; int x; } S; | |
6 | |
7 __attribute__ ((noinline)) int | |
8 f1 (S *s) | |
9 { | |
10 return __builtin_strcmp (s->s, "abc") != 0; | |
11 } | |
12 | |
13 __attribute__ ((noinline)) int | |
14 f2 (void) | |
15 { | |
16 return __builtin_strcmp (s, "abc") != 0; | |
17 } | |
18 | |
19 __attribute__ ((noinline)) int | |
20 f3 (S *s) | |
21 { | |
22 return __builtin_strcmp ("abc", s->s) != 0; | |
23 } | |
24 | |
25 __attribute__ ((noinline)) int | |
26 f4 (void) | |
27 { | |
28 return __builtin_strcmp ("abc", s) != 0; | |
29 } | |
30 | |
31 __attribute__ ((noinline)) int | |
32 f5 (S *s) | |
33 { | |
34 return __builtin_strncmp (s->s, "abc", 3) != 0; | |
35 } | |
36 | |
37 __attribute__ ((noinline)) int | |
38 f6 (void) | |
39 { | |
40 return __builtin_strncmp (s, "abc", 2) != 0; | |
41 } | |
42 | |
43 __attribute__ ((noinline)) int | |
44 f7 (S *s) | |
45 { | |
46 return __builtin_strncmp ("abc", s->s, 3) != 0; | |
47 } | |
48 | |
49 __attribute__ ((noinline)) int | |
50 f8 (void) | |
51 { | |
52 return __builtin_strncmp ("abc", s, 2) != 0; | |
53 } | |
54 | |
55 int main (void) | |
56 { | |
57 S ss = {{'a','b','c'}, 2}; | |
58 | |
59 if (f1 (&ss) != 0 || f2 () != 1 || f3 (&ss) != 0 || | |
60 f4 () != 1 || f5 (&ss) != 0 || f6 () != 0 || | |
61 f7 (&ss) != 0 || f8 () != 0) | |
62 __builtin_abort (); | |
63 | |
64 return 0; | |
65 } | |
66 | |
67 /* { dg-final { scan-tree-dump-times "cmp_eq \\(" 8 "strlen" } } */ |