Daily bump.
[official-gcc.git] / gcc / testsuite / gcc.dg / autopar / pr69062.c
blobe039349467f0b45e4591a90d49c0a61c07382436
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -ftree-parallelize-loops=2" } */
4 #include <stdbool.h>
6 typedef unsigned long HARD_REG_ELT_TYPE;
7 typedef HARD_REG_ELT_TYPE HARD_REG_SET[1];
8 struct target_ira
10 HARD_REG_SET x_ira_prohibited_class_mode_regs[1][1];
12 extern struct target_ira *this_target_ira;
13 static inline bool
14 ira_object_conflict_iter_cond ()
18 static inline bool
19 check_hard_reg_p (int num_objects, int hard_regno,
20 HARD_REG_SET * conflict_regs, HARD_REG_SET profitable_regs)
22 int j, nwords, nregs;
23 if ((! !
24 (((this_target_ira->
25 x_ira_prohibited_class_mode_regs)[0][0])[(hard_regno) /
26 ((unsigned) (8 * 8))] &
27 (((HARD_REG_ELT_TYPE) (1)) <<
28 ((hard_regno) % ((unsigned) (8 * 8)))))))
29 return false;
30 nwords = num_objects;
31 for (j = 0; j < nregs; j++)
33 int k;
34 int set_to_test_start = 0, set_to_test_end = nwords;
35 if (nregs == nwords)
37 if (0)
38 set_to_test_start = nwords - j - 1;
39 else
40 set_to_test_start = j;
42 for (k = set_to_test_start; k < set_to_test_end; k++)
43 if ((! !
44 ((conflict_regs[k])[(hard_regno + j) / ((unsigned) (8 * 8))] &
45 (((HARD_REG_ELT_TYPE) (1)) <<
46 ((hard_regno + j) % ((unsigned) (8 * 8)))))))
47 break;
48 if (k != set_to_test_end)
49 break;
51 return j == nregs;
54 void
55 improve_allocation (void)
57 int j, k, n, hregno, conflict_hregno, base_cost, class_size, word, nwords;
58 int check, spill_cost, min_cost, nregs, conflict_nregs, r, best;
59 int costs[81];
60 HARD_REG_SET conflicting_regs[2], profitable_hard_regs;
61 int a;
62 for (;;)
64 nwords = a;
65 for (word = 0; word < nwords; word++)
67 for (; ira_object_conflict_iter_cond ();)
69 for (r = conflict_hregno;
70 r < conflict_hregno + conflict_nregs; r++)
71 if (check_hard_reg_p
72 (a, r, conflicting_regs, profitable_hard_regs))
73 costs[r] += spill_cost;
75 if (check_hard_reg_p
76 (a, hregno, conflicting_regs, profitable_hard_regs)
77 && min_cost > costs[hregno])
79 best = hregno;
81 for (; ira_object_conflict_iter_cond ();)
83 if (best + nregs <= conflict_hregno
84 || conflict_hregno + conflict_nregs <= best)
85 continue;