aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/vect/vect-switch-ifcvt-1.c
blob: 2e3a9ae3c24919ef3e0ba9008f35178cc221de00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/* { dg-require-effective-target vect_condition } */
#include "tree-vect.h"

extern void abort (void);

int
f1 (char *s)
{
  int c = 0;
  int i;
  for (i = 0; i < 64; i++)
    {
      switch (*s)
	{
	case ',':
	case '|':
	  c++;
	}
      s++;
    }
  return c;
}

int
f2 (char *s)
{
  int c = 0;
  int i;
  for (i = 0; i < 64; i++)
    {
      if (*s != '#')
	{
	  switch (*s)
	    {
	    case ',':
	    case '|':
	      c++;
	    }
	}
      s++;
    }
  return c;
}

int
f3 (char *s)
{
  int c = 0;
  int i;
  for (i = 0; i < 64; i++)
    {
      if (*s != '#')
        if (*s == ',' || *s == '|' || *s == '@' || *s == '*')
	  c++;
      s++;
    }
  return c;
}


int
f4 (char *s)
{
  int c = 0;
  int i;
  for (i = 0; i < 64; i++)
    {
      if (*s == ',' || *s == '|' || *s == '@' || *s == '*')
	c++;
      s++;
    }
  return c;
}

#define CHECK(f, str, res) \
  __builtin_strcpy(buf, str); n = f(buf); if (n != res) abort();

int
main ()
{
  int n;
  char buf[64];

  __builtin_memset (buf, 0, sizeof buf);

  check_vect ();

  CHECK (f1, ",,,,,,,,,,", 10);
  CHECK (f1, "||||||||||", 10);
  CHECK (f1, "aaaaaaaaaa", 0);
  CHECK (f1, "", 0);
  CHECK (f1, ",|,|xxxxxx", 4);

  CHECK (f2, ",,,,,,,,,,", 10);
  CHECK (f2, "||||||||||", 10);
  CHECK (f2, "aaaaaaaaaa", 0);
  CHECK (f2, "", 0);
  CHECK (f2, ",|,|xxxxxx", 4);

  CHECK (f3, ",,,,,,,,,,", 10);
  CHECK (f3, "||||||||||", 10);
  CHECK (f3, "aaaaaaaaaa", 0);
  CHECK (f3, "", 0);
  CHECK (f3, ",|,|xxxxxx", 4);

  CHECK (f4, ",,,,,,,,,,", 10);
  CHECK (f4, "||||||||||", 10);
  CHECK (f4, "aaaaaaaaaa", 0);
  CHECK (f4, "", 0);
  CHECK (f4, ",|,|xxxxxx", 4);

  return 0;
}

/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 4 "vect"  } } */