| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O2 -ftree-parallelize-loops=2" } */ |
| 3 |
|
| 4 |
#include <stdbool.h> |
| 5 |
|
| 6 |
typedef unsigned long HARD_REG_ELT_TYPE; |
| 7 |
typedef HARD_REG_ELT_TYPE HARD_REG_SET[1]; |
| 8 |
struct target_ira |
| 9 |
{ |
| 10 |
HARD_REG_SET x_ira_prohibited_class_mode_regs[1][1]; |
| 11 |
}; |
| 12 |
extern struct target_ira *this_target_ira; |
| 13 |
static inline bool |
| 14 |
ira_object_conflict_iter_cond () |
| 15 |
{ |
| 16 |
} |
| 17 |
|
| 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) |
| 21 |
{ |
| 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++) |
| 32 |
{ |
| 33 |
int k; |
| 34 |
int set_to_test_start = 0, set_to_test_end = nwords; |
| 35 |
if (nregs == nwords) |
| 36 |
{ |
| 37 |
if (0) |
| 38 |
set_to_test_start = nwords - j - 1; |
| 39 |
else |
| 40 |
set_to_test_start = j; |
| 41 |
} |
| 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; |
| 50 |
} |
| 51 |
return j == nregs; |
| 52 |
} |
| 53 |
|
| 54 |
void |
| 55 |
improve_allocation (void) |
| 56 |
{ |
| 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 (;;) |
| 63 |
{ |
| 64 |
nwords = a; |
| 65 |
for (word = 0; word < nwords; word++) |
| 66 |
{ |
| 67 |
for (; ira_object_conflict_iter_cond ();) |
| 68 |
{ |
| 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; |
| 74 |
} |
| 75 |
if (check_hard_reg_p |
| 76 |
(a, hregno, conflicting_regs, profitable_hard_regs) |
| 77 |
&& min_cost > costs[hregno]) |
| 78 |
{ |
| 79 |
best = hregno; |
| 80 |
} |
| 81 |
for (; ira_object_conflict_iter_cond ();) |
| 82 |
{ |
| 83 |
if (best + nregs <= conflict_hregno |
| 84 |
|| conflict_hregno + conflict_nregs <= best) |
| 85 |
continue; |
| 86 |
} |
| 87 |
} |
| 88 |
} |
| 89 |
} |