Imported Upstream version 4.8.1
[platform/upstream/gcc48.git] / gcc / testsuite / gcc.target / sh / pr51244-15.c
1 /* Check that the redundant test removal code in the *cbranch_t split works
2    as expected on non-SH2A targets.  Because on SH2A the movrt instruction
3    is used, this test is re-used and checked differently in pr51244-16.c.  */
4 /* { dg-do compile { target "sh*-*-*" } } */
5 /* { dg-options "-O2" } */
6 /* { dg-skip-if "" { "sh*-*-*" } { "-m5*" "-m2a*" } { "" } } */
7 /* { dg-final { scan-assembler-times "tst" 6 } } */
8 /* { dg-final { scan-assembler-times "movt" 6 } } */
9 /* { dg-final { scan-assembler-times "xor" 3 } } */
10 /* { dg-final { scan-assembler-not "extu|exts|negc" } } */
11
12 typedef char bool;
13
14 int
15 test_0 (int a, int b, int c, int* d)
16 {
17   /* non SH2A: 1x tst, 1x movt, 1x xor
18          SH2A: 1x tst, 1x movrt  */
19   bool x = a == 0;
20   d[2] = !x;
21   return x ? b : c;
22 }
23
24 int
25 test_1 (int a, int b, int c, int* d)
26 {
27   /* 1x tst, 1x movt  */
28   bool x = a != 0;
29   d[2] = !x;
30   return x ? b : c;
31 }
32
33 int
34 test_2 (int a, int b, int c, char* d)
35 {
36   /* Check that there is no sign/zero-extension before the store.
37      non SH2A: 1x tst, 1x movt, 1x xor
38          SH2A: 1x tst, 1x movrt  */
39   bool x = a == 0;
40   d[2] = !x;
41   return x ? b : c;
42 }
43
44 int
45 test_3 (int a, int b, int c, char* d)
46 {
47   /* Check that there is no sign/zero-extension before the store.
48      1x tst, 1x movt  */
49   bool x = a != 0;
50   d[2] = !x;
51   return x ? b : c;
52 }
53
54 int
55 test_4 (int a, int b, int c, char* d)
56 {
57   /* 1x tst, 1x movt  */
58   bool x = a != 0;
59   d[2] = !x;
60   return !x ? b : c;
61 }
62
63 int
64 test_5 (int a, int b, int c, char* d)
65 {
66   /* non SH2A: 1x tst, 1x movt, 1x xor
67          SH2A: 1x tst, 1x movrt  */
68   bool x = a == 0;
69   d[2] = !x;
70   return !x ? b : c;
71 }