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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [strlenopt-18g.c] - Blame information for rev 754

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

Line No. Rev Author Line
1 689 jeremybenn
/* This test needs runtime that provides stpcpy function.  */
2
/* { dg-do run { target *-*-linux* } } */
3
/* { dg-options "-O2 -fdump-tree-strlen" } */
4
 
5
#define USE_GNU
6
#include "strlenopt.h"
7
 
8
__attribute__((noinline, noclone)) char *
9
fn1 (int x, int y, int z)
10
{
11
  static char buf[40];
12
  const char *p;
13
  switch (x)
14
    {
15
    case 0:
16
      p = "abcd";
17
      break;
18
    case 1:
19
      p = "efgh";
20
      break;
21
    case 2:
22
      p = "ijkl";
23
      break;
24
    default:
25
      p = "mnopq";
26
      break;
27
    }
28
  if (y)
29
    {
30
      strcpy (buf, p);
31
      if (z)
32
        strcat (buf, "ABCDEFG");
33
      else
34
        strcat (buf, "HIJKLMN");
35
    }
36
  else
37
    {
38
      strcpy (buf, p + 1);
39
      if (z)
40
        strcat (buf, "OPQ");
41
      else
42
        strcat (buf, "RST");
43
    }
44
  return buf;
45
}
46
 
47
int
48
main ()
49
{
50
  int i;
51
  for (i = 0; i < 5; i++)
52
    {
53
      const char *p = "abcdefghijklmnopq" + (i < 3 ? i : 3) * 4;
54
      const char *q;
55
      int j = i >= 3;
56
      fn1 (i ? 0 : 1, 1, 1);
57
      q = fn1 (i, 0, 0);
58
      if (memcmp (q, p + 1, 3 + j) != 0 || memcmp (q + 3 + j, "RST", 4) != 0)
59
        abort ();
60
      fn1 (i ? 0 : 1, 0, 1);
61
      q = fn1 (i, 1, 0);
62
      if (memcmp (q, p, 4 + j) != 0 || memcmp (q + 4 + j, "HIJKLMN", 8) != 0)
63
        abort ();
64
      fn1 (i ? 0 : 1, 1, 0);
65
      q = fn1 (i, 0, 1);
66
      if (memcmp (q, p + 1, 3 + j) != 0 || memcmp (q + 3 + j, "OPQ", 4) != 0)
67
        abort ();
68
      fn1 (i ? 0 : 1, 0, 0);
69
      q = fn1 (i, 1, 1);
70
      if (memcmp (q, p, 4 + j) != 0 || memcmp (q + 4 + j, "ABCDEFG", 8) != 0)
71
        abort ();
72
    }
73
  return 0;
74
}
75
 
76
/* { dg-final { scan-tree-dump-times "strlen \\(" 0 "strlen" } } */
77
/* { dg-final { scan-tree-dump-times "memcpy \\(" 4 "strlen" } } */
78
/* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen" } } */
79
/* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen" } } */
80
/* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen" } } */
81
/* { dg-final { scan-tree-dump-times "stpcpy \\(" 2 "strlen" } } */
82
/* { 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.