1 /* Check that the SH specific sh_treg_combine RTL optimization pass works as
2 expected. */
3 /* { dg-do compile } */
4 /* { dg-options "-O2 -fno-tree-dominator-opts -fno-tree-vrp" } */
5
6 /* { dg-final { scan-assembler-not "not\t" } } */
7 /* { dg-final { scan-assembler-times "cmp/eq" 2 } } */
8 /* { dg-final { scan-assembler-times "cmp/hi" 4 } } */
9 /* { dg-final { scan-assembler-times "cmp/gt" 2 } } */
10
11 /* { dg-final { scan-assembler-times "tst" 7 { target { ! sh2a } } } } */
12 /* { dg-final { scan-assembler-times "movt" 2 { target { ! sh2a } } } } */
13
14 /* { dg-final { scan-assembler-times "tst" 6 { target { sh2a } } } } */
15 /* { dg-final { scan-assembler-not "movt" { target { sh2a } } } } */
16 /* { dg-final { scan-assembler-times "nott" 2 { target { sh2a } } } } */
17
18
19 /* non-SH2A: 2x tst, 1x movt, 2x cmp/eq, 1x cmp/hi
20 SH2A: 1x tst, 1x nott, 2x cmp/eq, 1x cmp/hi */
21 static inline int
22 blk_oversized_queue_0 (int* q)
23 {
24 if (q[2])
25 return q[1] == 5;
26 return (q[0] != 5);
27 }
28
29 int __attribute__ ((noinline))
30 get_request_0 (int* q, int rw)
31 {
32 if (blk_oversized_queue_0 (q))
33 {
34 if ((rw == 1) || (rw == 0))
35 return -33;
36 return 0;
37 }
38 return -100;
39 }
40
41
42 /* 1x tst, 1x cmp/gt, 1x cmp/hi
43 On SH2A mem loads/stores have a wrong length of 4 bytes and thus will
44 not be placed in a delay slot. This introduces an extra cmp/gt insn. */
45 static inline int
46 blk_oversized_queue_1 (int* q)
47 {
48 if (q[2])
49 return q[1] > 5;
50 return (q[0] > 5);
51 }
52
53 int __attribute__ ((noinline))
54 get_request_1 (int* q, int rw)
55 {
56 if (blk_oversized_queue_1 (q))
57 {
58 if ((rw == 1) || (rw == 0))
59 return -33;
60 return 0;
61 }
62 return -100;
63 }
64
65
66 /* 1x tst, 1x cmp/gt, 1x cmp/hi, 1x cmp/hi */
67 static inline int
68 blk_oversized_queue_2 (int* q)
69 {
70 if (q[2])
71 return q[1] > 5;
72 return (q[0] < 5);
73 }
74
75 int __attribute__ ((noinline))
76 get_request_2 (int* q, int rw)
77 {
78 if (blk_oversized_queue_2 (q))
79 {
80 if ((rw == 1) || (rw == 0))
81 return -33;
82 return 0;
83 }
84 return -100;
85 }
86
87
88 /* 3x tst, 1x movt, 1x cmp/hi, 1x not */
89 static inline int
90 blk_oversized_queue_5 (int* q)
91 {
92 if (q[2])
93 return q[1] != 0;
94 return q[0] == 0;
95 }
96
97 int __attribute__ ((noinline))
98 get_request_5 (int* q, int rw)
99 {
100 if (blk_oversized_queue_5 (q))
101 {
102 if ((rw == 1) || (rw == 0))
103 return -33;
104 return 0;
105 }
106 return -100;
107 }