PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / 20040311-1.c
blob013d869abf4de1f483d9ba815c703bfb686d9e19
1 /* Copyright (C) 2004 Free Software Foundation.
3 Check that constant folding and RTL simplification of -(x >> y) doesn't
4 break anything and produces the expected results.
6 Written by Roger Sayle, 11th March 2004. */
8 extern void abort (void);
10 #define INT_BITS (sizeof(int)*8)
12 int test1(int x)
14 return -(x >> (INT_BITS-1));
17 int test2(unsigned int x)
19 return -((int)(x >> (INT_BITS-1)));
22 int test3(int x)
24 int y;
25 y = INT_BITS-1;
26 return -(x >> y);
29 int test4(unsigned int x)
31 int y;
32 y = INT_BITS-1;
33 return -((int)(x >> y));
36 int main()
38 if (test1(0) != 0)
39 abort ();
40 if (test1(1) != 0)
41 abort ();
42 if (test1(-1) != 1)
43 abort ();
45 if (test2(0) != 0)
46 abort ();
47 if (test2(1) != 0)
48 abort ();
49 if (test2((unsigned int)-1) != -1)
50 abort ();
52 if (test3(0) != 0)
53 abort ();
54 if (test3(1) != 0)
55 abort ();
56 if (test3(-1) != 1)
57 abort ();
59 if (test4(0) != 0)
60 abort ();
61 if (test4(1) != 0)
62 abort ();
63 if (test4((unsigned int)-1) != -1)
64 abort ();
66 return 0;