blob: cd724e2ebc4665b8110014b0ae07643486bbcdf1 (
plain) (
blame)
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
|
/*
20040311-1.c from the execute part of the gcc torture suite.
*/
#include <testfwk.h>
#ifdef __SDCC
#pragma std_c99
#endif
/* Copyright (C) 2004 Free Software Foundation.
Check that constant folding and RTL simplification of -(x >> y) doesn't
break anything and produces the expected results.
Written by Roger Sayle, 11th March 2004. */
#define INT_BITS (sizeof(int)*8)
int ftest1(int x)
{
return -(x >> (INT_BITS-1));
}
int ftest2(unsigned int x)
{
return -((int)(x >> (INT_BITS-1)));
}
int ftest3(int x)
{
int y;
y = INT_BITS-1;
return -(x >> y);
}
int ftest4(unsigned int x)
{
int y;
y = INT_BITS-1;
return -((int)(x >> y));
}
void
testTortureExecute (void)
{
if (ftest1(0) != 0)
ASSERT (0);
if (ftest1(1) != 0)
ASSERT (0);
if (ftest1(-1) != 1)
ASSERT (0);
if (ftest2(0) != 0)
ASSERT (0);
if (ftest2(1) != 0)
ASSERT (0);
if (ftest2((unsigned int)-1) != -1)
ASSERT (0);
if (ftest3(0) != 0)
ASSERT (0);
if (ftest3(1) != 0)
ASSERT (0);
if (ftest3(-1) != 1)
ASSERT (0);
if (ftest4(0) != 0)
ASSERT (0);
if (ftest4(1) != 0)
ASSERT (0);
if (ftest4((unsigned int)-1) != -1)
ASSERT (0);
return;
}
|