[C++ PATCH] Deprecate -ffriend-injection
[official-gcc.git] / gcc / testsuite / gcc.dg / fold-eqandshift-1.c
blobd2154c88aa166bb4b54927a54f5fc955f1f87aad
1 /* PR middle-end/21137 */
2 /* { dg-do compile } */
3 /* { dg-options "-O2 -fdump-tree-original" } */
4 extern void foo();
6 void test1(int a)
8 if ((a >> 3) & 1)
9 foo ();
12 void test2(int b)
14 if ((b >> 3) & 4)
15 foo ();
18 int test3(int c)
20 return (c >> 3) & 1;
23 int test4(int d)
25 return (d >> 3) & 4;
28 #if __INT_MAX__ == 32767
29 #define INT_BITS 16
30 #elif __INT_MAX__ == 2147483647
31 #define INT_BITS 32
32 #elif __INT_MAX__ == 9223372036854775807
33 #define INT_BITS 64
34 #else
35 #error Please add support for your target here.
36 #endif
38 void test5(int e)
40 if ((e >> (INT_BITS - 1)) & 64)
41 foo();
44 void test6(unsigned int f)
46 if ((f >> (INT_BITS - 1)) & 64)
47 foo();
50 /* { dg-final { scan-tree-dump-times "\\(a \& 8\\) != 0" 1 "original" } } */
51 /* { dg-final { scan-tree-dump-times "\\(b \& 32\\) != 0" 1 "original" } } */
52 /* { dg-final { scan-tree-dump-times "c >> 3 \& 1" 1 "original" } } */
53 /* { dg-final { scan-tree-dump-times "d >> 3 \& 4" 1 "original" } } */
54 /* { dg-final { scan-tree-dump-times "e < 0" 1 "original" } } */
55 /* { dg-final { scan-tree-dump-times "if \\(0\\)" 1 "original" } } */