summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/sh/pr51244-20.c
blob: a9ded46351114f1b916703d51b07357e9ab12667 (plain)
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/* Check that the SH specific sh_treg_combine RTL optimization pass works as
   expected.  On SH2A the expected insns are slightly different, see
   pr51244-21.c.  */
/* { dg-do compile }  */
/* { dg-options "-O2" } */
/* { dg-skip-if "" { "sh*-*-*" } { "-m5*" "-m2a*" } { "" } } */
/* { dg-final { scan-assembler-times "tst" 6 } } */
/* { dg-final { scan-assembler-times "movt" 1 } } */
/* { dg-final { scan-assembler-times "cmp/eq" 2 } } */
/* { dg-final { scan-assembler-times "cmp/hi" 4 } } */
/* { dg-final { scan-assembler-times "cmp/gt" 2 } } */
/* { dg-final { scan-assembler-times "not\t" 1 } } */


/* non-SH2A: 2x tst, 1x movt, 2x cmp/eq, 1x cmp/hi
   SH2A: 1x tst, 1x nott, 2x cmp/eq, 1x cmp/hi  */
static inline int
blk_oversized_queue_0 (int* q)
{
  if (q[2])
    return q[1] == 5; 
  return (q[0] != 5);
}

int __attribute__ ((noinline))
get_request_0 (int* q, int rw)
{
  if (blk_oversized_queue_0 (q))
    {
      if ((rw == 1) || (rw == 0))
	return -33;
      return 0;
    }
  return -100;
}


/* 1x tst, 1x cmp/gt, 1x cmp/hi
   On SH2A mem loads/stores have a wrong length of 4 bytes and thus will
   not be placed in a delay slot.  This introduces an extra cmp/gt insn.  */
static inline int
blk_oversized_queue_1 (int* q)
{
  if (q[2])
    return q[1] > 5; 
  return (q[0] > 5);
}

int __attribute__ ((noinline))
get_request_1 (int* q, int rw)
{
  if (blk_oversized_queue_1 (q))
    {
      if ((rw == 1) || (rw == 0))
	return -33;
      return 0;
    }
  return -100;
}


/* 1x tst, 1x cmp/gt, 1x cmp/hi, 1x cmp/hi  */
static inline int
blk_oversized_queue_2 (int* q)
{
  if (q[2])
    return q[1] > 5; 
  return (q[0] < 5);
}

int __attribute__ ((noinline))
get_request_2 (int* q, int rw)
{
  if (blk_oversized_queue_2 (q))
    {
      if ((rw == 1) || (rw == 0))
	return -33;
      return 0;
    }
  return -100;
}


/* 2x tst, 1x cmp/hi, 1x not  */
static inline int
blk_oversized_queue_5 (int* q)
{
  if (q[2])
    return q[1] != 0; 
  return q[0] == 0;
}

int __attribute__ ((noinline))
get_request_5 (int* q, int rw)
{
  if (blk_oversized_queue_5 (q))
    {
      if ((rw == 1) || (rw == 0))
	return -33;
      return 0;
    }
  return -100;
}