OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [strlenopt-11.c] - Blame information for rev 708

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 689 jeremybenn
/* { dg-do run } */
2
/* { dg-options "-O2 -fdump-tree-strlen" } */
3
 
4
#include "strlenopt.h"
5
 
6
__attribute__((noinline, noclone)) void
7
fn1 (char *p, const char *z, size_t *lp)
8
{
9
  char *q, *r, *s;
10
  char buf[64];
11
  size_t l[11];
12
  /* The first strlen stays, all the strcpy calls can be optimized
13
     into memcpy and most other strlen calls and all strchr calls
14
     optimized away.  l[6] = strlen (r); and l[9] = strlen (r); need
15
     to stay, because we need to invalidate the knowledge about
16
     r strlen after strcpy (q, "jklmnopqrst").  */
17
  l[0] = strlen (z);
18
  strcpy (buf, z);
19
  strcpy (p, "abcde");
20
  q = strchr (p, '\0');
21
  strcpy (q, "efghi");
22
  r = strchr (q, '\0');
23
  strcpy (r, buf);
24
  l[1] = strlen (p);
25
  l[2] = strlen (q);
26
  l[3] = strlen (r);
27
  strcpy (q, "jklmnopqrst");
28
  l[4] = strlen (p);
29
  l[5] = strlen (q);
30
  l[6] = strlen (r);
31
  s = strchr (q, '\0');
32
  strcpy (s, buf);
33
  l[7] = strlen (p);
34
  l[8] = strlen (q);
35
  l[9] = strlen (r);
36
  l[10] = strlen (s);
37
  memcpy (lp, l, sizeof l);
38
}
39
 
40
int
41
main ()
42
{
43
  char buf[64];
44
  size_t l[11];
45
  const char *volatile z = "ABCDEFG";
46
  memset (buf, '\0', sizeof buf);
47
  fn1 (buf, z, l);
48
  if (memcmp (buf, "abcdejklmnopqrstABCDEFG", 24) != 0)
49
    abort ();
50
  if (l[0] != 7)
51
    abort ();
52
  if (l[1] != 17 || l[2] != 12 || l[3] != 7)
53
    abort ();
54
  if (l[4] != 16 || l[5] != 11 || l[6] != 6)
55
    abort ();
56
  if (l[7] != 23 || l[8] != 18 || l[9] != 13 || l[10] != 7)
57
    abort ();
58
  return 0;
59
}
60
 
61
/* { dg-final { scan-tree-dump-times "strlen \\(" 3 "strlen" } } */
62
/* { dg-final { scan-tree-dump-times "memcpy \\(" 7 "strlen" } } */
63
/* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen" } } */
64
/* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen" } } */
65
/* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen" } } */
66
/* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen" } } */
67
/* { dg-final { scan-tree-dump-times "  D\.\[0-9_\]* = strlen \\(\[^\n\r\]*;\[\n\r\]*  l.0. = " 1 "strlen" } } */
68
/* { dg-final { scan-tree-dump-times "  D\.\[0-9_\]* = strlen \\(\[^\n\r\]*;\[\n\r\]*  l.6. = " 1 "strlen" } } */
69
/* { dg-final { scan-tree-dump-times "  D\.\[0-9_\]* = strlen \\(\[^\n\r\]*;\[\n\r\]*  l.9. = " 1 "strlen" } } */
70
/* { dg-final { cleanup-tree-dump "strlen" } } */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.