1 /* PR optimization/9888 */
2 /* Originator: Jim Bray <jb@as220.org> */
3 /* { dg-do run } */
4 /* { dg-require-effective-target ia32 } */
5 /* { dg-options "-mtune=k6 -Os" } */
6 
7 enum reload_type
8 {
9   RELOAD_FOR_INPUT, RELOAD_FOR_OUTPUT, RELOAD_FOR_INSN,
10   RELOAD_FOR_INPUT_ADDRESS, RELOAD_FOR_INPADDR_ADDRESS,
11   RELOAD_FOR_OUTPUT_ADDRESS, RELOAD_FOR_OUTADDR_ADDRESS,
12   RELOAD_FOR_OPERAND_ADDRESS, RELOAD_FOR_OPADDR_ADDR,
13   RELOAD_OTHER, RELOAD_FOR_OTHER_ADDRESS
14 };
15 
16 #define FOO_SIZE 3
17 
18 /* My results, varying with FOO_SIZE:
19    30: asm error "value of ..fff77 too large:
20    3 to 29: ....ff7d...
21    1 to 2: no error.  */
22 
23 struct reload
24 {
25    int foo[FOO_SIZE];
26    int opnum;
27    enum reload_type when_needed;
28    unsigned int optional:1;
29    unsigned int secondary_p:1;
30 };
31 
32 #define N_RELOADS  2
33 
34 struct reload rld[N_RELOADS];
35 int n_reloads = N_RELOADS;
36 
main(void)37 int main(void)
38 {
39   int i;
40 
41   enum reload_type operand_type[1];
42 
43   enum reload_type address_type[1];
44 
45   int operand_reloadnum[1];
46   int goal_alternative_matches[1];
47 
48   for (i = 0; i < n_reloads; i++)
49     {
50       if (rld[i].secondary_p
51           && rld[i].when_needed == operand_type[rld[i].opnum])
52         rld[i].when_needed = address_type[rld[i].opnum];
53 
54       if ((rld[i].when_needed == RELOAD_FOR_INPUT_ADDRESS
55            || rld[i].when_needed == RELOAD_FOR_OUTPUT_ADDRESS
56            || rld[i].when_needed == RELOAD_FOR_INPADDR_ADDRESS
57            || rld[i].when_needed == RELOAD_FOR_OUTADDR_ADDRESS)
58           && (operand_reloadnum[rld[i].opnum] < 0
59               || rld[operand_reloadnum[rld[i].opnum]].optional))
60         {
61 
62           if (rld[i].when_needed == RELOAD_FOR_INPADDR_ADDRESS
63               || rld[i].when_needed == RELOAD_FOR_OUTADDR_ADDRESS)
64             rld[i].when_needed = RELOAD_FOR_OPADDR_ADDR;
65           else
66             rld[i].when_needed = RELOAD_FOR_OPERAND_ADDRESS;
67         }
68 
69       if ((rld[i].when_needed == RELOAD_FOR_INPUT_ADDRESS
70            || rld[i].when_needed == RELOAD_FOR_INPADDR_ADDRESS)
71           && operand_reloadnum[rld[i].opnum] >= 0
72           && (rld[operand_reloadnum[rld[i].opnum]].when_needed
73               == RELOAD_OTHER))
74         rld[i].when_needed = RELOAD_FOR_OTHER_ADDRESS;
75 
76       if (goal_alternative_matches[rld[i].opnum] >= 0)
77         rld[i].opnum = goal_alternative_matches[rld[i].opnum];
78     }
79 
80   return 0;
81 }
82