PR rtl-optimization/87918
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / pr46939.c
blob0fd8607bbddefb71b91cdd002c431c650e295a0a
1 /* { dg-do compile } */
2 /* { dg-options "-O2" } */
4 __extension__ typedef __SIZE_TYPE__ size_t;
6 int
7 php_filter_parse_int (char const *str, unsigned int str_len, long *ret)
9 long ctx_value;
10 int sign;
11 int digit;
12 char const *end;
13 int tmp;
14 char const *tmp___0;
15 char const *tmp___1;
17 sign = 0;
18 digit = 0;
19 end = str + str_len;
20 switch ((int) *str)
22 case 45:
23 sign = 1;
24 case 43:
25 str++;
26 default:;
27 break;
29 if ((size_t) str < (size_t) end)
31 if ((int const) *str >= 49)
33 if ((int const) *str <= 57)
35 if (sign)
37 tmp = -1;
39 else
41 tmp = 1;
43 tmp___0 = str;
44 str++;
45 ctx_value = (long) (tmp * (int) ((int const) *tmp___0 - 48));
47 else
49 return (-1);
52 else
54 return (-1);
57 else
59 return (-1);
61 if (end - str > 19)
63 return (-1);
65 while ((size_t) str < (size_t) end)
67 if ((int const) *str >= 48)
69 if ((int const) *str <= 57)
71 tmp___1 = str;
72 str++;
73 digit = (int) ((int const) *tmp___1 - 48);
74 if (!sign)
76 if (ctx_value <=
77 (9223372036854775807L - (long) digit) / 10L)
79 ctx_value = ctx_value * 10L + (long) digit;
81 else
83 goto _L;
86 else
88 _L:
89 if (sign)
91 if (ctx_value >=
92 ((-0x7FFFFFFFFFFFFFFF - 1) + (long) digit) / 10L)
94 ctx_value = ctx_value * 10L - (long) digit;
96 else
98 return (-1);
101 else
103 return (-1);
107 else
109 return (-1);
112 else
114 return (-1);
117 *ret = ctx_value;
118 return (1);
121 /* { dg-final { scan-assembler-not "idiv" } } */