aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/sms-9.c
blob: c8dc28104aa37affc5250155ec12e742765ac732 (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
/* { dg-do run } */
/* { dg-options "-O2 -fmodulo-sched -fmodulo-sched-allow-regmoves" } */

#include <stdlib.h>
#include <stdarg.h>

struct df_ref_info
{
  unsigned int *begin;
  unsigned int *count;
};

extern void *memset (void *s, int c, __SIZE_TYPE__ n);


__attribute__ ((noinline))
int
df_reorganize_refs_by_reg_by_insn (struct df_ref_info *ref_info,
			           int num, unsigned int start)
{
  unsigned int m = num;
  unsigned int offset = 77;
  unsigned int r;

  for (r = start; r < m; r++)
    {
      ref_info->begin[r] = offset;
      offset += ref_info->count[r];
      ref_info->count[r] = 0;
    }

  return offset;
}

int
main ()
{
  struct df_ref_info temp;
  int num = 100;
  unsigned int start = 5;
  int i, offset;

  temp.begin = malloc (100 * sizeof (unsigned int));
  temp.count = malloc (100 * sizeof (unsigned int));

  memset (temp.begin, 0, sizeof (unsigned int) * num);
  memset (temp.count, 0, sizeof (unsigned int) * num);

  for (i = 0; i < num; i++)
    temp.count[i] = i + 1;

  offset = df_reorganize_refs_by_reg_by_insn (&temp, num, start);

  if (offset != 5112)
    abort ();

  free (temp.begin);
  free (temp.count);
  return 0;
}