Line data Source code
1 : /* Assign reload pseudos.
2 : Copyright (C) 2010-2026 Free Software Foundation, Inc.
3 : Contributed by Vladimir Makarov <vmakarov@redhat.com>.
4 :
5 : This file is part of GCC.
6 :
7 : GCC is free software; you can redistribute it and/or modify it under
8 : the terms of the GNU General Public License as published by the Free
9 : Software Foundation; either version 3, or (at your option) any later
10 : version.
11 :
12 : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 : WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 : FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 : for more details.
16 :
17 : You should have received a copy of the GNU General Public License
18 : along with GCC; see the file COPYING3. If not see
19 : <http://www.gnu.org/licenses/>. */
20 :
21 :
22 : /* This file's main objective is to assign hard registers to reload
23 : pseudos. It also tries to allocate hard registers to other
24 : pseudos, but at a lower priority than the reload pseudos. The pass
25 : does not transform the RTL.
26 :
27 : We must allocate a hard register to every reload pseudo. We try to
28 : increase the chances of finding a viable allocation by assigning
29 : the pseudos in order of fewest available hard registers first. If
30 : we still fail to find a hard register, we spill other (non-reload)
31 : pseudos in order to make room.
32 :
33 : find_hard_regno_for finds hard registers for allocation without
34 : spilling. spill_for does the same with spilling. Both functions
35 : use a cost model to determine the most profitable choice of hard
36 : and spill registers.
37 :
38 : Once we have finished allocating reload pseudos, we also try to
39 : assign registers to other (non-reload) pseudos. This is useful if
40 : hard registers were freed up by the spilling just described.
41 :
42 : We try to assign hard registers by collecting pseudos into threads.
43 : These threads contain reload and inheritance pseudos that are
44 : connected by copies (move insns). Doing this improves the chances
45 : of pseudos in the thread getting the same hard register and, as a
46 : result, of allowing some move insns to be deleted.
47 :
48 : When we assign a hard register to a pseudo, we decrease the cost of
49 : using the same hard register for pseudos that are connected by
50 : copies.
51 :
52 : If two hard registers have the same frequency-derived cost, we
53 : prefer hard registers with higher priorities. The mapping of
54 : registers to priorities is controlled by the register_priority
55 : target hook. For example, x86-64 has a few register priorities:
56 : hard registers with and without REX prefixes have different
57 : priorities. This permits us to generate smaller code as insns
58 : without REX prefixes are shorter.
59 :
60 : If a few hard registers are still equally good for the assignment,
61 : we choose the least used hard register. It is called leveling and
62 : may be profitable for some targets.
63 :
64 : Only insns with changed allocation pseudos are processed on the
65 : next constraint pass.
66 :
67 : The pseudo live-ranges are used to find conflicting pseudos.
68 :
69 : For understanding the code, it is important to keep in mind that
70 : inheritance, split, and reload pseudos created since last
71 : constraint pass have regno >= lra_constraint_new_regno_start.
72 : Inheritance and split pseudos created on any pass are in the
73 : corresponding bitmaps. Inheritance and split pseudos since the
74 : last constraint pass have also the corresponding non-negative
75 : restore_regno. */
76 :
77 : #include "config.h"
78 : #include "system.h"
79 : #include "coretypes.h"
80 : #include "backend.h"
81 : #include "target.h"
82 : #include "rtl.h"
83 : #include "tree.h"
84 : #include "predict.h"
85 : #include "df.h"
86 : #include "memmodel.h"
87 : #include "tm_p.h"
88 : #include "insn-config.h"
89 : #include "regs.h"
90 : #include "ira.h"
91 : #include "recog.h"
92 : #include "rtl-error.h"
93 : #include "sparseset.h"
94 : #include "lra.h"
95 : #include "lra-int.h"
96 : #include "function-abi.h"
97 :
98 : /* Current iteration number of the pass and current iteration number
99 : of the pass after the latest spill pass when any former reload
100 : pseudo was spilled. */
101 : int lra_assignment_iter;
102 : int lra_assignment_iter_after_spill;
103 :
104 : /* Flag of spilling former reload pseudos on this pass. */
105 : static bool former_reload_pseudo_spill_p;
106 :
107 : /* Array containing corresponding values of function
108 : lra_get_allocno_class. It is used to speed up the code. */
109 : static enum reg_class *regno_allocno_class_array;
110 :
111 : /* Array containing lengths of pseudo live ranges. It is used to
112 : speed up the code. */
113 : static int *regno_live_length;
114 :
115 : /* Information about the thread to which a pseudo belongs. Threads are
116 : a set of connected reload and inheritance pseudos with the same set of
117 : available hard registers. Lone registers belong to their own threads. */
118 : struct regno_assign_info
119 : {
120 : /* First/next pseudo of the same thread. */
121 : int first, next;
122 : /* Frequency of the thread (execution frequency of only reload
123 : pseudos in the thread when the thread contains a reload pseudo).
124 : Defined only for the first thread pseudo. */
125 : int freq;
126 : };
127 :
128 : /* Map regno to the corresponding regno assignment info. */
129 : static struct regno_assign_info *regno_assign_info;
130 :
131 : /* All inherited, subreg or optional pseudos created before last spill
132 : sub-pass. Such pseudos are permitted to get memory instead of hard
133 : regs. */
134 : static bitmap_head non_reload_pseudos;
135 :
136 : /* Process a pseudo copy with execution frequency COPY_FREQ connecting
137 : REGNO1 and REGNO2 to form threads. */
138 : static void
139 1626747 : process_copy_to_form_thread (int regno1, int regno2, int copy_freq)
140 : {
141 1626747 : int last, regno1_first, regno2_first;
142 :
143 1626747 : lra_assert (regno1 >= lra_constraint_new_regno_start
144 : && regno2 >= lra_constraint_new_regno_start);
145 1626747 : regno1_first = regno_assign_info[regno1].first;
146 1626747 : regno2_first = regno_assign_info[regno2].first;
147 1626747 : if (regno1_first != regno2_first)
148 : {
149 2614806 : for (last = regno2_first;
150 4241553 : regno_assign_info[last].next >= 0;
151 2614806 : last = regno_assign_info[last].next)
152 2614806 : regno_assign_info[last].first = regno1_first;
153 1626747 : regno_assign_info[last].first = regno1_first;
154 1626747 : regno_assign_info[last].next = regno_assign_info[regno1_first].next;
155 1626747 : regno_assign_info[regno1_first].next = regno2_first;
156 1626747 : regno_assign_info[regno1_first].freq
157 1626747 : += regno_assign_info[regno2_first].freq;
158 : }
159 1626747 : regno_assign_info[regno1_first].freq -= 2 * copy_freq;
160 1626747 : lra_assert (regno_assign_info[regno1_first].freq >= 0);
161 1626747 : }
162 :
163 : /* Initialize REGNO_ASSIGN_INFO and form threads. */
164 : static void
165 1579332 : init_regno_assign_info (void)
166 : {
167 1579332 : int i, regno1, regno2, max_regno = max_reg_num ();
168 1579332 : lra_copy_t cp;
169 :
170 1579332 : regno_assign_info = XNEWVEC (struct regno_assign_info, max_regno);
171 104412970 : for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)
172 : {
173 102833638 : regno_assign_info[i].first = i;
174 102833638 : regno_assign_info[i].next = -1;
175 102833638 : regno_assign_info[i].freq = lra_reg_info[i].freq;
176 : }
177 : /* Form the threads. */
178 4457042 : for (i = 0; (cp = lra_get_copy (i)) != NULL; i++)
179 2877710 : if ((regno1 = cp->regno1) >= lra_constraint_new_regno_start
180 2877710 : && (regno2 = cp->regno2) >= lra_constraint_new_regno_start
181 2877710 : && reg_renumber[regno1] < 0 && lra_reg_info[regno1].nrefs != 0
182 1670562 : && reg_renumber[regno2] < 0 && lra_reg_info[regno2].nrefs != 0
183 2877710 : && (ira_class_hard_regs_num[regno_allocno_class_array[regno1]]
184 1667228 : == ira_class_hard_regs_num[regno_allocno_class_array[regno2]]))
185 1626747 : process_copy_to_form_thread (regno1, regno2, cp->freq);
186 1579332 : }
187 :
188 : /* Free REGNO_ASSIGN_INFO. */
189 : static void
190 1579332 : finish_regno_assign_info (void)
191 : {
192 1579332 : free (regno_assign_info);
193 0 : }
194 :
195 : /* The function is used to sort *reload* and *inheritance* pseudos to
196 : try to assign them hard registers. We put pseudos from the same
197 : thread always nearby. */
198 : static int
199 258534442 : reload_pseudo_compare_func (const void *v1p, const void *v2p)
200 : {
201 258534442 : int r1 = *(const int *) v1p, r2 = *(const int *) v2p;
202 258534442 : enum reg_class cl1 = regno_allocno_class_array[r1];
203 258534442 : enum reg_class cl2 = regno_allocno_class_array[r2];
204 258534442 : int diff;
205 :
206 258534442 : lra_assert (r1 >= lra_constraint_new_regno_start
207 : && r2 >= lra_constraint_new_regno_start);
208 :
209 : /* Prefer to assign reload registers with smaller classes first to
210 : guarantee assignment to all reload registers. */
211 258534442 : if ((diff = (ira_class_hard_regs_num[cl1]
212 258534442 : - ira_class_hard_regs_num[cl2])) != 0)
213 : return diff;
214 : /* Allocate bigger pseudos first to avoid register file
215 : fragmentation. */
216 242350410 : if ((diff
217 242350410 : = (ira_reg_class_max_nregs[cl2][lra_reg_info[r2].biggest_mode]
218 242350410 : - ira_reg_class_max_nregs[cl1][lra_reg_info[r1].biggest_mode])) != 0)
219 : return diff;
220 240048802 : if ((diff = (regno_assign_info[regno_assign_info[r2].first].freq
221 240048802 : - regno_assign_info[regno_assign_info[r1].first].freq)) != 0)
222 : return diff;
223 : /* Put pseudos from the thread nearby. */
224 136281524 : if ((diff = regno_assign_info[r1].first - regno_assign_info[r2].first) != 0)
225 : return diff;
226 : /* Prefer pseudos with longer live ranges. It sets up better
227 : preferred hard registers for the thread pseudos and decreases
228 : register-register moves between the thread pseudos. */
229 18088999 : if ((diff = regno_live_length[r2] - regno_live_length[r1]) != 0)
230 : return diff;
231 : /* If regs are equally good, sort by their numbers, so that the
232 : results of qsort leave nothing to chance. */
233 8218789 : return r1 - r2;
234 : }
235 :
236 : /* The function is used to sort *non-reload* pseudos to try to assign
237 : them hard registers. The order calculation is simpler than in the
238 : previous function and based on the pseudo frequency usage. */
239 : static int
240 1135099204 : pseudo_compare_func (const void *v1p, const void *v2p)
241 : {
242 1135099204 : int r1 = *(const int *) v1p, r2 = *(const int *) v2p;
243 1135099204 : int diff;
244 :
245 : /* Assign hard reg to static chain pointer first pseudo when
246 : non-local goto is used. */
247 1135099204 : if ((diff = (non_spilled_static_chain_regno_p (r2)
248 1135099204 : - non_spilled_static_chain_regno_p (r1))) != 0)
249 : return diff;
250 :
251 : /* Prefer to assign more frequently used registers first. */
252 1135095936 : if ((diff = lra_reg_info[r2].freq - lra_reg_info[r1].freq) != 0)
253 : return diff;
254 :
255 : /* If regs are equally good, sort by their numbers, so that the
256 : results of qsort leave nothing to chance. */
257 673605440 : return r1 - r2;
258 : }
259 :
260 : /* Arrays of size LRA_LIVE_MAX_POINT mapping a program point to the
261 : pseudo live ranges with given start point. We insert only live
262 : ranges of pseudos interesting for assignment purposes. They are
263 : reload pseudos and pseudos assigned to hard registers. */
264 : static lra_live_range_t *start_point_ranges;
265 :
266 : /* Used as a flag that a live range is not inserted in the start point
267 : chain. */
268 : static struct lra_live_range not_in_chain_mark;
269 :
270 : /* Create and set up START_POINT_RANGES. */
271 : static void
272 1579332 : create_live_range_start_chains (void)
273 : {
274 1579332 : int i, max_regno;
275 1579332 : lra_live_range_t r;
276 :
277 1579332 : start_point_ranges = XCNEWVEC (lra_live_range_t, lra_live_max_point);
278 1579332 : max_regno = max_reg_num ();
279 105992302 : for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)
280 102833638 : if (i >= lra_constraint_new_regno_start || reg_renumber[i] >= 0)
281 : {
282 109195809 : for (r = lra_reg_info[i].live_ranges; r != NULL; r = r->next)
283 : {
284 58272583 : r->start_next = start_point_ranges[r->start];
285 58272583 : start_point_ranges[r->start] = r;
286 : }
287 : }
288 : else
289 : {
290 54735649 : for (r = lra_reg_info[i].live_ranges; r != NULL; r = r->next)
291 2825237 : r->start_next = ¬_in_chain_mark;
292 : }
293 1579332 : }
294 :
295 : /* Insert live ranges of pseudo REGNO into start chains if they are
296 : not there yet. */
297 : static void
298 505505735 : insert_in_live_range_start_chain (int regno)
299 : {
300 505505735 : lra_live_range_t r = lra_reg_info[regno].live_ranges;
301 :
302 505505735 : if (r->start_next != ¬_in_chain_mark)
303 : return;
304 204144 : for (; r != NULL; r = r->next)
305 : {
306 129836 : r->start_next = start_point_ranges[r->start];
307 129836 : start_point_ranges[r->start] = r;
308 : }
309 : }
310 :
311 : /* Free START_POINT_RANGES. */
312 : static void
313 1579332 : finish_live_range_start_chains (void)
314 : {
315 1579332 : gcc_assert (start_point_ranges != NULL);
316 1579332 : free (start_point_ranges);
317 1579332 : start_point_ranges = NULL;
318 1579332 : }
319 :
320 : /* Map: program point -> bitmap of all pseudos living at the point and
321 : assigned to hard registers. */
322 : static bitmap_head *live_hard_reg_pseudos;
323 : static bitmap_obstack live_hard_reg_pseudos_bitmap_obstack;
324 :
325 : /* reg_renumber corresponding to pseudos marked in
326 : live_hard_reg_pseudos. reg_renumber might be not matched to
327 : live_hard_reg_pseudos but live_pseudos_reg_renumber always reflects
328 : live_hard_reg_pseudos. */
329 : static int *live_pseudos_reg_renumber;
330 :
331 : /* Sparseset used to calculate living hard reg pseudos for some program
332 : point range. */
333 : static sparseset live_range_hard_reg_pseudos;
334 :
335 : /* Sparseset used to calculate living reload/inheritance pseudos for
336 : some program point range. */
337 : static sparseset live_range_reload_inheritance_pseudos;
338 :
339 : /* Allocate and initialize the data about living pseudos at program
340 : points. */
341 : static void
342 1579332 : init_lives (void)
343 : {
344 1579332 : int i, max_regno = max_reg_num ();
345 :
346 1579332 : live_range_hard_reg_pseudos = sparseset_alloc (max_regno);
347 1579332 : live_range_reload_inheritance_pseudos = sparseset_alloc (max_regno);
348 1579332 : live_hard_reg_pseudos = XNEWVEC (bitmap_head, lra_live_max_point);
349 1579332 : bitmap_obstack_initialize (&live_hard_reg_pseudos_bitmap_obstack);
350 92374262 : for (i = 0; i < lra_live_max_point; i++)
351 89215598 : bitmap_initialize (&live_hard_reg_pseudos[i],
352 : &live_hard_reg_pseudos_bitmap_obstack);
353 1579332 : live_pseudos_reg_renumber = XNEWVEC (int, max_regno);
354 252870178 : for (i = 0; i < max_regno; i++)
355 251290846 : live_pseudos_reg_renumber[i] = -1;
356 1579332 : }
357 :
358 : /* Free the data about living pseudos at program points. */
359 : static void
360 1579332 : finish_lives (void)
361 : {
362 1579332 : sparseset_free (live_range_hard_reg_pseudos);
363 1579332 : sparseset_free (live_range_reload_inheritance_pseudos);
364 1579332 : free (live_hard_reg_pseudos);
365 1579332 : bitmap_obstack_release (&live_hard_reg_pseudos_bitmap_obstack);
366 1579332 : free (live_pseudos_reg_renumber);
367 1579332 : }
368 :
369 : /* Update the LIVE_HARD_REG_PSEUDOS and LIVE_PSEUDOS_REG_RENUMBER
370 : entries for pseudo REGNO. Assume that the register has been
371 : spilled if FREE_P, otherwise assume that it has been assigned
372 : reg_renumber[REGNO] (if >= 0). We also insert the pseudo live
373 : ranges in the start chains when it is assumed to be assigned to a
374 : hard register because we use the chains of pseudos assigned to hard
375 : registers during allocation. */
376 : static void
377 49434474 : update_lives (int regno, bool free_p)
378 : {
379 49434474 : int p;
380 49434474 : lra_live_range_t r;
381 :
382 49434474 : if (reg_renumber[regno] < 0)
383 : return;
384 49434474 : live_pseudos_reg_renumber[regno] = free_p ? -1 : reg_renumber[regno];
385 108029844 : for (r = lra_reg_info[regno].live_ranges; r != NULL; r = r->next)
386 : {
387 624185914 : for (p = r->start; p <= r->finish; p++)
388 565590544 : if (free_p)
389 65584355 : bitmap_clear_bit (&live_hard_reg_pseudos[p], regno);
390 : else
391 : {
392 500006189 : bitmap_set_bit (&live_hard_reg_pseudos[p], regno);
393 500006189 : insert_in_live_range_start_chain (regno);
394 : }
395 : }
396 : }
397 :
398 : /* Sparseset used to calculate reload pseudos conflicting with a given
399 : pseudo when we are trying to find a hard register for the given
400 : pseudo. */
401 : static sparseset conflict_reload_and_inheritance_pseudos;
402 :
403 : /* Map: program point -> bitmap of all reload and inheritance pseudos
404 : living at the point. */
405 : static bitmap_head *live_reload_and_inheritance_pseudos;
406 : static bitmap_obstack live_reload_and_inheritance_pseudos_bitmap_obstack;
407 :
408 : /* Allocate and initialize data about living reload pseudos at any
409 : given program point. */
410 : static void
411 1579332 : init_live_reload_and_inheritance_pseudos (void)
412 : {
413 1579332 : int i, p, max_regno = max_reg_num ();
414 1579332 : lra_live_range_t r;
415 :
416 1579332 : conflict_reload_and_inheritance_pseudos = sparseset_alloc (max_regno);
417 1579332 : live_reload_and_inheritance_pseudos = XNEWVEC (bitmap_head, lra_live_max_point);
418 1579332 : bitmap_obstack_initialize (&live_reload_and_inheritance_pseudos_bitmap_obstack);
419 92374262 : for (p = 0; p < lra_live_max_point; p++)
420 89215598 : bitmap_initialize (&live_reload_and_inheritance_pseudos[p],
421 : &live_reload_and_inheritance_pseudos_bitmap_obstack);
422 1579332 : if ((unsigned) (max_regno - lra_constraint_new_regno_start)
423 1579332 : >= (1U << lra_max_pseudos_points_log2_considered_for_preferences)
424 1579332 : / (lra_live_max_point + 1))
425 16 : return;
426 1579316 : bitmap_head start_points;
427 1579316 : bitmap_initialize (&start_points,
428 : &live_hard_reg_pseudos_bitmap_obstack);
429 13647767 : for (i = lra_constraint_new_regno_start; i < max_regno; i++)
430 23573868 : for (r = lra_reg_info[i].live_ranges; r != NULL; r = r->next)
431 11505417 : bitmap_set_bit (&start_points, r->start);
432 13647767 : for (i = lra_constraint_new_regno_start; i < max_regno; i++)
433 : {
434 23573868 : for (r = lra_reg_info[i].live_ranges; r != NULL; r = r->next)
435 : {
436 11505417 : bitmap_iterator bi;
437 11505417 : unsigned p;
438 46986546 : EXECUTE_IF_SET_IN_BITMAP (&start_points, r->start, p, bi)
439 : {
440 46311436 : if (p > (unsigned) r->finish)
441 : break;
442 35481129 : bitmap_set_bit (&live_reload_and_inheritance_pseudos[p], i);
443 : }
444 : }
445 : }
446 1579316 : bitmap_clear (&start_points);
447 : }
448 :
449 : /* Finalize data about living reload pseudos at any given program
450 : point. */
451 : static void
452 1579332 : finish_live_reload_and_inheritance_pseudos (void)
453 : {
454 1579332 : sparseset_free (conflict_reload_and_inheritance_pseudos);
455 1579332 : free (live_reload_and_inheritance_pseudos);
456 1579332 : bitmap_obstack_release (&live_reload_and_inheritance_pseudos_bitmap_obstack);
457 1579332 : }
458 :
459 : /* The value used to check that cost of given hard reg is really
460 : defined currently. */
461 : static int curr_hard_regno_costs_check = 0;
462 : /* Array used to check that cost of the corresponding hard reg (the
463 : array element index) is really defined currently. */
464 : static int hard_regno_costs_check[FIRST_PSEUDO_REGISTER];
465 : /* The current costs of allocation of hard regs. Defined only if the
466 : value of the corresponding element of the previous array is equal to
467 : CURR_HARD_REGNO_COSTS_CHECK. */
468 : static int hard_regno_costs[FIRST_PSEUDO_REGISTER];
469 :
470 : /* Adjust cost of HARD_REGNO by INCR. Reset the cost first if it is
471 : not defined yet. */
472 : static inline void
473 24638224 : adjust_hard_regno_cost (int hard_regno, int incr)
474 : {
475 24638224 : if (hard_regno_costs_check[hard_regno] != curr_hard_regno_costs_check)
476 12288322 : hard_regno_costs[hard_regno] = 0;
477 24638224 : hard_regno_costs_check[hard_regno] = curr_hard_regno_costs_check;
478 24638224 : hard_regno_costs[hard_regno] += incr;
479 24638224 : }
480 :
481 : /* Try to find a free hard register for pseudo REGNO. Return the
482 : hard register on success and set *COST to the cost of using
483 : that register. (If several registers have equal cost, the one with
484 : the highest priority wins.) Return -1 on failure.
485 :
486 : If FIRST_P, return the first available hard reg ignoring other
487 : criteria, e.g. allocation cost. This approach results in less hard
488 : reg pool fragmentation and permit to allocate hard regs to reload
489 : pseudos in complicated situations where pseudo sizes are different.
490 :
491 : If TRY_ONLY_HARD_REGNO >= 0, consider only that hard register,
492 : otherwise consider all hard registers in REGNO's class.
493 :
494 : If REGNO_SET is not empty, only hard registers from the set are
495 : considered. */
496 : static int
497 14336164 : find_hard_regno_for_1 (int regno, int *cost, int try_only_hard_regno,
498 : bool first_p, HARD_REG_SET regno_set)
499 : {
500 14336164 : HARD_REG_SET conflict_set;
501 14336164 : int best_cost = INT_MAX, best_priority = INT_MIN, best_usage = INT_MAX;
502 14336164 : lra_live_range_t r;
503 14336164 : int p, i, j, rclass_size, best_hard_regno, priority, hard_regno;
504 14336164 : int hr, conflict_hr, nregs;
505 14336164 : machine_mode biggest_mode;
506 14336164 : unsigned int k, conflict_regno;
507 14336164 : poly_int64 offset;
508 14336164 : int val, biggest_nregs, nregs_diff;
509 14336164 : enum reg_class rclass;
510 14336164 : bitmap_iterator bi;
511 14336164 : bool *rclass_intersect_p;
512 14336164 : HARD_REG_SET impossible_start_hard_regs, available_regs;
513 :
514 28672328 : if (hard_reg_set_empty_p (regno_set))
515 14113767 : conflict_set = lra_no_alloc_regs;
516 : else
517 222397 : conflict_set = ~regno_set | lra_no_alloc_regs;
518 14336164 : rclass = regno_allocno_class_array[regno];
519 14336164 : rclass_intersect_p = ira_reg_classes_intersect_p[rclass];
520 14336164 : curr_hard_regno_costs_check++;
521 14336164 : sparseset_clear (conflict_reload_and_inheritance_pseudos);
522 14336164 : sparseset_clear (live_range_hard_reg_pseudos);
523 14336164 : conflict_set |= lra_reg_info[regno].conflict_hard_regs;
524 14336164 : biggest_mode = lra_reg_info[regno].biggest_mode;
525 30588927 : for (r = lra_reg_info[regno].live_ranges; r != NULL; r = r->next)
526 : {
527 131908223 : EXECUTE_IF_SET_IN_BITMAP (&live_hard_reg_pseudos[r->start], 0, k, bi)
528 115655460 : if (rclass_intersect_p[regno_allocno_class_array[k]])
529 102208120 : sparseset_set_bit (live_range_hard_reg_pseudos, k);
530 140977170 : EXECUTE_IF_SET_IN_BITMAP (&live_reload_and_inheritance_pseudos[r->start],
531 : 0, k, bi)
532 124724407 : if (lra_reg_info[k].preferred_hard_regno1 >= 0
533 36685484 : && live_pseudos_reg_renumber[k] < 0
534 33935223 : && rclass_intersect_p[regno_allocno_class_array[k]])
535 32055531 : sparseset_set_bit (conflict_reload_and_inheritance_pseudos, k);
536 2871494663 : for (p = r->start + 1; p <= r->finish; p++)
537 : {
538 2855241900 : lra_live_range_t r2;
539 :
540 2855241900 : for (r2 = start_point_ranges[p];
541 4862419838 : r2 != NULL;
542 2007177938 : r2 = r2->start_next)
543 : {
544 2007177938 : if (live_pseudos_reg_renumber[r2->regno] < 0
545 639221968 : && r2->regno >= lra_constraint_new_regno_start
546 638070495 : && lra_reg_info[r2->regno].preferred_hard_regno1 >= 0
547 367134563 : && rclass_intersect_p[regno_allocno_class_array[r2->regno]])
548 358627720 : sparseset_set_bit (conflict_reload_and_inheritance_pseudos,
549 : r2->regno);
550 1648550218 : else if (live_pseudos_reg_renumber[r2->regno] >= 0
551 1367955970 : && rclass_intersect_p
552 1367955970 : [regno_allocno_class_array[r2->regno]])
553 1255641352 : sparseset_set_bit (live_range_hard_reg_pseudos, r2->regno);
554 : }
555 : }
556 : }
557 14336164 : if ((hard_regno = lra_reg_info[regno].preferred_hard_regno1) >= 0)
558 : {
559 5957194 : adjust_hard_regno_cost
560 5957194 : (hard_regno, -lra_reg_info[regno].preferred_hard_regno_profit1);
561 5957194 : if ((hard_regno = lra_reg_info[regno].preferred_hard_regno2) >= 0)
562 1888575 : adjust_hard_regno_cost
563 1888575 : (hard_regno, -lra_reg_info[regno].preferred_hard_regno_profit2);
564 : }
565 : #ifdef STACK_REGS
566 14336164 : if (lra_reg_info[regno].no_stack_p)
567 497466 : for (i = FIRST_STACK_REG; i <= LAST_STACK_REG; i++)
568 442192 : SET_HARD_REG_BIT (conflict_set, i);
569 : #endif
570 14336164 : sparseset_clear_bit (conflict_reload_and_inheritance_pseudos, regno);
571 14336164 : val = lra_reg_info[regno].val;
572 14336164 : offset = lra_reg_info[regno].offset;
573 14336164 : impossible_start_hard_regs = lra_reg_info[regno].exclude_start_hard_regs;
574 200171960 : EXECUTE_IF_SET_IN_SPARSESET (live_range_hard_reg_pseudos, conflict_regno)
575 : {
576 190504300 : conflict_hr = live_pseudos_reg_renumber[conflict_regno];
577 190504300 : if (lra_reg_val_equal_p (conflict_regno, val, offset))
578 : {
579 882269 : conflict_hr = live_pseudos_reg_renumber[conflict_regno];
580 882269 : nregs = hard_regno_nregs (conflict_hr,
581 882269 : lra_reg_info[conflict_regno].biggest_mode);
582 : /* Remember about multi-register pseudos. For example, 2
583 : hard register pseudos can start on the same hard register
584 : but cannot start on HR and HR+1/HR-1. */
585 888693 : for (hr = conflict_hr + 1;
586 888693 : hr < FIRST_PSEUDO_REGISTER && hr < conflict_hr + nregs;
587 : hr++)
588 6424 : SET_HARD_REG_BIT (impossible_start_hard_regs, hr);
589 887519 : for (hr = conflict_hr - 1;
590 887519 : hr >= 0 && (int) end_hard_regno (biggest_mode, hr) > conflict_hr;
591 : hr--)
592 5250 : SET_HARD_REG_BIT (impossible_start_hard_regs, hr);
593 : }
594 : else
595 : {
596 189622031 : machine_mode biggest_conflict_mode
597 189622031 : = lra_reg_info[conflict_regno].biggest_mode;
598 189622031 : int biggest_conflict_nregs
599 189622031 : = hard_regno_nregs (conflict_hr, biggest_conflict_mode);
600 :
601 189622031 : nregs_diff
602 189622031 : = (biggest_conflict_nregs
603 189622031 : - hard_regno_nregs (conflict_hr,
604 189622031 : PSEUDO_REGNO_MODE (conflict_regno)));
605 189622031 : add_to_hard_reg_set (&conflict_set,
606 : biggest_conflict_mode,
607 : conflict_hr
608 : - (WORDS_BIG_ENDIAN ? nregs_diff : 0));
609 379244062 : if (hard_reg_set_subset_p (reg_class_contents[rclass],
610 : conflict_set))
611 : return -1;
612 : }
613 : }
614 21118962 : EXECUTE_IF_SET_IN_SPARSESET (conflict_reload_and_inheritance_pseudos,
615 : conflict_regno)
616 22902604 : if (!lra_reg_val_equal_p (conflict_regno, val, offset))
617 : {
618 11196898 : lra_assert (live_pseudos_reg_renumber[conflict_regno] < 0);
619 11196898 : if ((hard_regno
620 11196898 : = lra_reg_info[conflict_regno].preferred_hard_regno1) >= 0)
621 : {
622 11196898 : adjust_hard_regno_cost
623 11196898 : (hard_regno,
624 : lra_reg_info[conflict_regno].preferred_hard_regno_profit1);
625 11196898 : if ((hard_regno
626 11196898 : = lra_reg_info[conflict_regno].preferred_hard_regno2) >= 0)
627 5595557 : adjust_hard_regno_cost
628 5595557 : (hard_regno,
629 : lra_reg_info[conflict_regno].preferred_hard_regno_profit2);
630 : }
631 : }
632 :
633 : /* If a reference/partner pseudo already has a hardreg, restrict this one
634 : to what the filter permits. */
635 9667660 : if (!lra_reg_info[regno].dependent_filters.is_empty ())
636 : {
637 : unsigned int i;
638 : dependent_filter *filter;
639 0 : FOR_EACH_VEC_ELT (lra_reg_info[regno].dependent_filters, i, filter)
640 : {
641 0 : int partner_regno = live_pseudos_reg_renumber[filter->partner_regno];
642 0 : if (partner_regno < 0)
643 0 : partner_regno = reg_renumber[filter->partner_regno];
644 0 : if (partner_regno < 0)
645 0 : continue;
646 :
647 0 : const HARD_REG_SET *allowed
648 0 : = lra_get_dependent_filter (filter->id, filter->mode,
649 : (unsigned int) partner_regno,
650 : filter->partner_mode, filter->is_ref);
651 0 : conflict_set |= ~*allowed;
652 : }
653 : }
654 :
655 : /* Make sure that all registers in a multi-word pseudo belong to the
656 : required class. */
657 9667660 : conflict_set |= ~reg_class_contents[rclass];
658 9667660 : lra_assert (rclass != NO_REGS);
659 9667660 : rclass_size = ira_class_hard_regs_num[rclass];
660 9667660 : best_hard_regno = -1;
661 9667660 : hard_regno = ira_class_hard_regs[rclass][0];
662 9667660 : biggest_nregs = hard_regno_nregs (hard_regno, biggest_mode);
663 9667660 : nregs_diff = (biggest_nregs
664 9667660 : - hard_regno_nregs (hard_regno, PSEUDO_REGNO_MODE (regno)));
665 9667660 : available_regs = reg_class_contents[rclass] & ~lra_no_alloc_regs;
666 125062748 : for (i = 0; i < rclass_size; i++)
667 : {
668 115468861 : if (try_only_hard_regno >= 0)
669 : hard_regno = try_only_hard_regno;
670 : else
671 115397096 : hard_regno = ira_class_hard_regs[rclass][i];
672 115468861 : if (! overlaps_hard_reg_set_p (conflict_set,
673 115468861 : PSEUDO_REGNO_MODE (regno), hard_regno)
674 60456349 : && targetm.hard_regno_mode_ok (hard_regno, PSEUDO_REGNO_MODE (regno))
675 : /* We cannot use prohibited_class_mode_regs for all classes
676 : because it is not defined for all classes. */
677 60301069 : && (ira_allocno_class_translate[rclass] != rclass
678 23060888 : || ! TEST_HARD_REG_BIT (ira_prohibited_class_mode_regs
679 23060888 : [rclass][biggest_mode],
680 : hard_regno))
681 60300775 : && ! TEST_HARD_REG_BIT (impossible_start_hard_regs, hard_regno)
682 175767811 : && (nregs_diff == 0
683 4633 : || (WORDS_BIG_ENDIAN
684 : ? (hard_regno - nregs_diff >= 0
685 : && TEST_HARD_REG_BIT (available_regs,
686 : hard_regno - nregs_diff))
687 4633 : : TEST_HARD_REG_BIT (available_regs,
688 4633 : hard_regno + nregs_diff))))
689 : {
690 60298568 : if (hard_regno_costs_check[hard_regno]
691 60298568 : != curr_hard_regno_costs_check)
692 : {
693 54941704 : hard_regno_costs_check[hard_regno] = curr_hard_regno_costs_check;
694 54941704 : hard_regno_costs[hard_regno] = 0;
695 : }
696 121764441 : for (j = 0;
697 121764441 : j < hard_regno_nregs (hard_regno, PSEUDO_REGNO_MODE (regno));
698 : j++)
699 61465873 : if (! crtl->abi->clobbers_full_reg_p (hard_regno + j)
700 61465873 : && ! df_regs_ever_live_p (hard_regno + j))
701 : /* It needs save restore. */
702 11983894 : hard_regno_costs[hard_regno]
703 5991947 : += (2
704 16452590 : * REG_FREQ_FROM_BB (ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb)
705 15441287 : + 1);
706 60298568 : priority = targetm.register_priority (hard_regno);
707 50895273 : if (best_hard_regno < 0 || hard_regno_costs[hard_regno] < best_cost
708 109273444 : || (hard_regno_costs[hard_regno] == best_cost
709 25800365 : && (priority > best_priority
710 25701826 : || (targetm.register_usage_leveling_p ()
711 25701826 : && priority == best_priority
712 6551005 : && best_usage > lra_hard_reg_usage[hard_regno]))))
713 : {
714 14137703 : best_hard_regno = hard_regno;
715 14137703 : best_cost = hard_regno_costs[hard_regno];
716 14137703 : best_priority = priority;
717 14137703 : best_usage = lra_hard_reg_usage[hard_regno];
718 : }
719 : }
720 115468861 : if (try_only_hard_regno >= 0 || (first_p && best_hard_regno >= 0))
721 : break;
722 : }
723 9667660 : if (best_hard_regno >= 0)
724 9403295 : *cost = best_cost - lra_reg_info[regno].freq;
725 : return best_hard_regno;
726 : }
727 :
728 : /* A wrapper for find_hard_regno_for_1 (see comments for that function
729 : description). This function tries to find a hard register for
730 : preferred class first if it is worth. */
731 : static int
732 14116704 : find_hard_regno_for (int regno, int *cost, int try_only_hard_regno, bool first_p)
733 : {
734 14116704 : int hard_regno;
735 14116704 : HARD_REG_SET regno_set;
736 :
737 : /* Only original pseudos can have a different preferred class. */
738 14116704 : if (try_only_hard_regno < 0 && regno < lra_new_regno_start)
739 : {
740 1229675 : enum reg_class pref_class = reg_preferred_class (regno);
741 :
742 1229675 : if (regno_allocno_class_array[regno] != pref_class)
743 : {
744 444794 : hard_regno = find_hard_regno_for_1 (regno, cost, -1, first_p,
745 222397 : reg_class_contents[pref_class]);
746 222397 : if (hard_regno >= 0)
747 : return hard_regno;
748 : }
749 : }
750 14113767 : CLEAR_HARD_REG_SET (regno_set);
751 14113767 : return find_hard_regno_for_1 (regno, cost, try_only_hard_regno, first_p,
752 14113767 : regno_set);
753 : }
754 :
755 : /* Current value used for checking elements in
756 : update_hard_regno_preference_check. */
757 : static int curr_update_hard_regno_preference_check;
758 : /* If an element value is equal to the above variable value, then the
759 : corresponding regno has been processed for preference
760 : propagation. */
761 : static int *update_hard_regno_preference_check;
762 :
763 : /* Update the preference for using HARD_REGNO for pseudos that are
764 : connected directly or indirectly with REGNO. Apply divisor DIV
765 : to any preference adjustments.
766 :
767 : The more indirectly a pseudo is connected, the smaller its effect
768 : should be. We therefore increase DIV on each "hop". */
769 : static void
770 9714823 : update_hard_regno_preference (int regno, int hard_regno, int div)
771 : {
772 9714823 : int another_regno, cost;
773 9714823 : lra_copy_t cp, next_cp;
774 :
775 : /* Search depth 5 seems to be enough. */
776 9714823 : if (div > (1 << 5))
777 : return;
778 17748027 : for (cp = lra_reg_info[regno].copies; cp != NULL; cp = next_cp)
779 : {
780 8128138 : if (cp->regno1 == regno)
781 : {
782 3716253 : next_cp = cp->regno1_next;
783 3716253 : another_regno = cp->regno2;
784 : }
785 4411885 : else if (cp->regno2 == regno)
786 : {
787 4411885 : next_cp = cp->regno2_next;
788 4411885 : another_regno = cp->regno1;
789 : }
790 : else
791 0 : gcc_unreachable ();
792 8128138 : if (reg_renumber[another_regno] < 0
793 4485279 : && (update_hard_regno_preference_check[another_regno]
794 4485279 : != curr_update_hard_regno_preference_check))
795 : {
796 3076899 : update_hard_regno_preference_check[another_regno]
797 3076899 : = curr_update_hard_regno_preference_check;
798 3076899 : cost = cp->freq < div ? 1 : cp->freq / div;
799 3076899 : lra_setup_reload_pseudo_preferenced_hard_reg
800 3076899 : (another_regno, hard_regno, cost);
801 3076899 : update_hard_regno_preference (another_regno, hard_regno, div * 2);
802 : }
803 : }
804 : }
805 :
806 : /* Return prefix title for pseudo REGNO. */
807 : static const char *
808 96 : pseudo_prefix_title (int regno)
809 : {
810 96 : return
811 96 : (regno < lra_constraint_new_regno_start ? ""
812 96 : : bitmap_bit_p (&lra_inheritance_pseudos, regno) ? "inheritance "
813 95 : : bitmap_bit_p (&lra_split_regs, regno) ? "split "
814 95 : : bitmap_bit_p (&lra_optional_reload_pseudos, regno) ? "optional reload "
815 93 : : bitmap_bit_p (&lra_subreg_reload_pseudos, regno) ? "subreg reload "
816 96 : : "reload ");
817 : }
818 :
819 : /* Update REG_RENUMBER and other pseudo preferences by assignment of
820 : HARD_REGNO to pseudo REGNO and print about it if PRINT_P. */
821 : void
822 6770283 : lra_setup_reg_renumber (int regno, int hard_regno, bool print_p)
823 : {
824 6770283 : int i, hr;
825 :
826 : /* We cannot just reassign hard register. */
827 6770283 : lra_assert (hard_regno < 0 || reg_renumber[regno] < 0);
828 132359 : if ((hr = hard_regno) < 0)
829 132359 : hr = reg_renumber[regno];
830 6770283 : reg_renumber[regno] = hard_regno;
831 6770283 : lra_assert (hr >= 0);
832 13745671 : for (i = 0; i < hard_regno_nregs (hr, PSEUDO_REGNO_MODE (regno)); i++)
833 6975388 : if (hard_regno < 0)
834 141569 : lra_hard_reg_usage[hr + i] -= lra_reg_info[regno].freq;
835 : else
836 6833819 : lra_hard_reg_usage[hr + i] += lra_reg_info[regno].freq;
837 6770283 : if (print_p && lra_dump_file != NULL)
838 192 : fprintf (lra_dump_file, " Assign %d to %sr%d (freq=%d)\n",
839 96 : reg_renumber[regno], pseudo_prefix_title (regno),
840 96 : regno, lra_reg_info[regno].freq);
841 6770283 : if (hard_regno >= 0)
842 : {
843 6637924 : curr_update_hard_regno_preference_check++;
844 6637924 : update_hard_regno_preference (regno, hard_regno, 1);
845 : }
846 6770283 : }
847 :
848 : /* Pseudos which occur in insns containing a particular pseudo. */
849 : static bitmap_head insn_conflict_pseudos;
850 :
851 : /* Bitmaps used to contain spill pseudos for given pseudo hard regno
852 : and best spill pseudos for given pseudo (and best hard regno). */
853 : static bitmap_head spill_pseudos_bitmap, best_spill_pseudos_bitmap;
854 :
855 : /* Current pseudo check for validity of elements in
856 : TRY_HARD_REG_PSEUDOS. */
857 : static int curr_pseudo_check;
858 : /* Array used for validity of elements in TRY_HARD_REG_PSEUDOS. */
859 : static int try_hard_reg_pseudos_check[FIRST_PSEUDO_REGISTER];
860 : /* Pseudos who hold given hard register at the considered points. */
861 : static bitmap_head try_hard_reg_pseudos[FIRST_PSEUDO_REGISTER];
862 :
863 : /* Set up try_hard_reg_pseudos for given program point P and class
864 : RCLASS. Those are pseudos living at P and assigned to a hard
865 : register of RCLASS. In other words, those are pseudos which can be
866 : spilled to assign a hard register of RCLASS to a pseudo living at
867 : P. */
868 : static void
869 132613 : setup_try_hard_regno_pseudos (int p, enum reg_class rclass)
870 : {
871 132613 : int i, hard_regno;
872 132613 : machine_mode mode;
873 132613 : unsigned int spill_regno;
874 132613 : bitmap_iterator bi;
875 :
876 : /* Find what pseudos could be spilled. */
877 960028 : EXECUTE_IF_SET_IN_BITMAP (&live_hard_reg_pseudos[p], 0, spill_regno, bi)
878 : {
879 827415 : mode = PSEUDO_REGNO_MODE (spill_regno);
880 827415 : hard_regno = live_pseudos_reg_renumber[spill_regno];
881 827415 : if (overlaps_hard_reg_set_p (reg_class_contents[rclass],
882 : mode, hard_regno))
883 : {
884 1260831 : for (i = hard_regno_nregs (hard_regno, mode) - 1; i >= 0; i--)
885 : {
886 642212 : if (try_hard_reg_pseudos_check[hard_regno + i]
887 642212 : != curr_pseudo_check)
888 : {
889 301778 : try_hard_reg_pseudos_check[hard_regno + i]
890 301778 : = curr_pseudo_check;
891 301778 : bitmap_clear (&try_hard_reg_pseudos[hard_regno + i]);
892 : }
893 642212 : bitmap_set_bit (&try_hard_reg_pseudos[hard_regno + i],
894 : spill_regno);
895 : }
896 : }
897 : }
898 132613 : }
899 :
900 : /* Assign temporarily HARD_REGNO to pseudo REGNO. Temporary
901 : assignment means that we might undo the data change. */
902 : static void
903 2053000 : assign_temporarily (int regno, int hard_regno)
904 : {
905 2053000 : int p;
906 2053000 : lra_live_range_t r;
907 :
908 4135326 : for (r = lra_reg_info[regno].live_ranges; r != NULL; r = r->next)
909 : {
910 13081418 : for (p = r->start; p <= r->finish; p++)
911 10999092 : if (hard_regno < 0)
912 5499546 : bitmap_clear_bit (&live_hard_reg_pseudos[p], regno);
913 : else
914 : {
915 5499546 : bitmap_set_bit (&live_hard_reg_pseudos[p], regno);
916 5499546 : insert_in_live_range_start_chain (regno);
917 : }
918 : }
919 2053000 : live_pseudos_reg_renumber[regno] = hard_regno;
920 2053000 : }
921 :
922 : /* Return true iff there is a reason why pseudo SPILL_REGNO should not
923 : be spilled. */
924 : static bool
925 306915 : must_not_spill_p (unsigned spill_regno)
926 : {
927 306915 : if ((pic_offset_table_rtx != NULL
928 90088 : && spill_regno == REGNO (pic_offset_table_rtx))
929 391426 : || ((int) spill_regno >= lra_constraint_new_regno_start
930 30279 : && ! bitmap_bit_p (&lra_inheritance_pseudos, spill_regno)
931 14066 : && ! bitmap_bit_p (&lra_split_regs, spill_regno)
932 11809 : && ! bitmap_bit_p (&lra_subreg_reload_pseudos, spill_regno)
933 11809 : && ! bitmap_bit_p (&lra_optional_reload_pseudos, spill_regno)))
934 : return true;
935 : /* A reload pseudo that requires a singleton register class should
936 : not be spilled.
937 : FIXME: this mitigates the issue on certain i386 patterns, but
938 : does not solve the general case where existing reloads fully
939 : cover a limited register class. */
940 291547 : if (!bitmap_bit_p (&non_reload_pseudos, spill_regno)
941 271059 : && reg_class_size [reg_preferred_class (spill_regno)] == 1
942 307055 : && reg_alternate_class (spill_regno) == NO_REGS)
943 390 : return true;
944 : return false;
945 : }
946 :
947 : /* Array used for sorting reload pseudos for subsequent allocation
948 : after spilling some pseudo. */
949 : static int *sorted_reload_pseudos;
950 :
951 : /* Spill some pseudos for a reload pseudo REGNO and return hard
952 : register which should be used for pseudo after spilling. The
953 : function adds spilled pseudos to SPILLED_PSEUDO_BITMAP. When we
954 : choose hard register (and pseudos occupying the hard registers and
955 : to be spilled), we take into account not only how REGNO will
956 : benefit from the spills but also how other reload pseudos not yet
957 : assigned to hard registers benefit from the spills too. In very
958 : rare cases, the function can fail and return -1.
959 :
960 : If FIRST_P, return the first available hard reg ignoring other
961 : criteria, e.g. allocation cost and cost of spilling non-reload
962 : pseudos. This approach results in less hard reg pool fragmentation
963 : and permit to allocate hard regs to reload pseudos in complicated
964 : situations where pseudo sizes are different. */
965 : static int
966 55348 : spill_for (int regno, bitmap spilled_pseudo_bitmap, bool first_p)
967 : {
968 55348 : int i, j, n, p, hard_regno, best_hard_regno, cost, best_cost, rclass_size;
969 55348 : int reload_hard_regno, reload_cost;
970 55348 : bool static_p, best_static_p;
971 55348 : machine_mode mode;
972 55348 : enum reg_class rclass;
973 55348 : unsigned int spill_regno, reload_regno, uid;
974 55348 : int insn_pseudos_num, best_insn_pseudos_num;
975 55348 : int bad_spills_num, smallest_bad_spills_num;
976 55348 : lra_live_range_t r;
977 55348 : bitmap_iterator bi;
978 :
979 55348 : rclass = regno_allocno_class_array[regno];
980 55348 : lra_assert (reg_renumber[regno] < 0 && rclass != NO_REGS);
981 55348 : bitmap_clear (&insn_conflict_pseudos);
982 55348 : bitmap_clear (&best_spill_pseudos_bitmap);
983 163335 : EXECUTE_IF_SET_IN_BITMAP (&lra_reg_info[regno].insn_bitmap, 0, uid, bi)
984 : {
985 107987 : struct lra_insn_reg *ir;
986 :
987 363514 : for (ir = lra_get_insn_regs (uid); ir != NULL; ir = ir->next)
988 255527 : if (ir->regno >= FIRST_PSEUDO_REGISTER)
989 245859 : bitmap_set_bit (&insn_conflict_pseudos, ir->regno);
990 : }
991 55348 : best_hard_regno = -1;
992 55348 : best_cost = INT_MAX;
993 55348 : best_static_p = true;
994 55348 : best_insn_pseudos_num = INT_MAX;
995 55348 : smallest_bad_spills_num = INT_MAX;
996 55348 : rclass_size = ira_class_hard_regs_num[rclass];
997 55348 : mode = PSEUDO_REGNO_MODE (regno);
998 : /* Invalidate try_hard_reg_pseudos elements. */
999 55348 : curr_pseudo_check++;
1000 115384 : for (r = lra_reg_info[regno].live_ranges; r != NULL; r = r->next)
1001 192649 : for (p = r->start; p <= r->finish; p++)
1002 132613 : setup_try_hard_regno_pseudos (p, rclass);
1003 428588 : for (i = 0; i < rclass_size; i++)
1004 : {
1005 373240 : hard_regno = ira_class_hard_regs[rclass][i];
1006 373240 : bitmap_clear (&spill_pseudos_bitmap);
1007 762501 : for (j = hard_regno_nregs (hard_regno, mode) - 1; j >= 0; j--)
1008 : {
1009 389261 : if (hard_regno + j >= FIRST_PSEUDO_REGISTER)
1010 : break;
1011 389261 : if (try_hard_reg_pseudos_check[hard_regno + j] != curr_pseudo_check)
1012 78795 : continue;
1013 310466 : lra_assert (!bitmap_empty_p (&try_hard_reg_pseudos[hard_regno + j]));
1014 310466 : bitmap_ior_into (&spill_pseudos_bitmap,
1015 310466 : &try_hard_reg_pseudos[hard_regno + j]);
1016 : }
1017 : /* Spill pseudos. */
1018 373240 : static_p = false;
1019 664397 : EXECUTE_IF_SET_IN_BITMAP (&spill_pseudos_bitmap, 0, spill_regno, bi)
1020 306915 : if (must_not_spill_p (spill_regno))
1021 15758 : goto fail;
1022 291157 : else if (non_spilled_static_chain_regno_p (spill_regno))
1023 0 : static_p = true;
1024 357482 : insn_pseudos_num = 0;
1025 357482 : bad_spills_num = 0;
1026 357482 : if (lra_dump_file != NULL)
1027 0 : fprintf (lra_dump_file, " Trying %d:", hard_regno);
1028 357482 : sparseset_clear (live_range_reload_inheritance_pseudos);
1029 648387 : EXECUTE_IF_SET_IN_BITMAP (&spill_pseudos_bitmap, 0, spill_regno, bi)
1030 : {
1031 290905 : if (bitmap_bit_p (&insn_conflict_pseudos, spill_regno))
1032 49325 : insn_pseudos_num++;
1033 290905 : if (spill_regno >= (unsigned int) lra_bad_spill_regno_start)
1034 0 : bad_spills_num++;
1035 290905 : for (r = lra_reg_info[spill_regno].live_ranges;
1036 974435 : r != NULL;
1037 683530 : r = r->next)
1038 : {
1039 61069128 : for (p = r->start; p <= r->finish; p++)
1040 : {
1041 60385598 : lra_live_range_t r2;
1042 :
1043 60385598 : for (r2 = start_point_ranges[p];
1044 103674518 : r2 != NULL;
1045 43288920 : r2 = r2->start_next)
1046 43288920 : if (r2->regno >= lra_constraint_new_regno_start)
1047 24970014 : sparseset_set_bit (live_range_reload_inheritance_pseudos,
1048 : r2->regno);
1049 : }
1050 : }
1051 : }
1052 357482 : n = 0;
1053 357482 : if (sparseset_cardinality (live_range_reload_inheritance_pseudos)
1054 357482 : <= (unsigned)param_lra_max_considered_reload_pseudos)
1055 14345076 : EXECUTE_IF_SET_IN_SPARSESET (live_range_reload_inheritance_pseudos,
1056 : reload_regno)
1057 6952625 : if ((int) reload_regno != regno
1058 6688461 : && (ira_reg_classes_intersect_p
1059 6688461 : [rclass][regno_allocno_class_array[reload_regno]])
1060 5865567 : && live_pseudos_reg_renumber[reload_regno] < 0
1061 10386672 : && find_hard_regno_for (reload_regno, &cost, -1, first_p) < 0)
1062 1612126 : sorted_reload_pseudos[n++] = reload_regno;
1063 648387 : EXECUTE_IF_SET_IN_BITMAP (&spill_pseudos_bitmap, 0, spill_regno, bi)
1064 : {
1065 290905 : update_lives (spill_regno, true);
1066 290905 : if (lra_dump_file != NULL)
1067 0 : fprintf (lra_dump_file, " spill %d(freq=%d)",
1068 0 : spill_regno, lra_reg_info[spill_regno].freq);
1069 : }
1070 357482 : hard_regno = find_hard_regno_for (regno, &cost, -1, first_p);
1071 357482 : if (hard_regno >= 0)
1072 : {
1073 276476 : assign_temporarily (regno, hard_regno);
1074 276476 : qsort (sorted_reload_pseudos, n, sizeof (int),
1075 : reload_pseudo_compare_func);
1076 2153641 : for (j = 0; j < n; j++)
1077 : {
1078 1600689 : reload_regno = sorted_reload_pseudos[j];
1079 1600689 : lra_assert (live_pseudos_reg_renumber[reload_regno] < 0);
1080 3201378 : if ((reload_hard_regno
1081 1600689 : = find_hard_regno_for (reload_regno,
1082 : &reload_cost, -1, first_p)) >= 0)
1083 : {
1084 750024 : if (lra_dump_file != NULL)
1085 0 : fprintf (lra_dump_file, " assign %d(cost=%d)",
1086 : reload_regno, reload_cost);
1087 750024 : assign_temporarily (reload_regno, reload_hard_regno);
1088 750024 : cost += reload_cost;
1089 : }
1090 : }
1091 557220 : EXECUTE_IF_SET_IN_BITMAP (&spill_pseudos_bitmap, 0, spill_regno, bi)
1092 : {
1093 280744 : rtx_insn_list *x;
1094 :
1095 280744 : cost += lra_reg_info[spill_regno].freq;
1096 280744 : if (ira_reg_equiv[spill_regno].memory != NULL
1097 270561 : || ira_reg_equiv[spill_regno].constant != NULL)
1098 12126 : for (x = ira_reg_equiv[spill_regno].init_insns;
1099 21955 : x != NULL;
1100 9829 : x = x->next ())
1101 29045 : cost -= REG_FREQ_FROM_BB (BLOCK_FOR_INSN (x->insn ()));
1102 : }
1103 : /* Avoid spilling static chain pointer pseudo when non-local
1104 : goto is used. */
1105 276476 : if ((! static_p && best_static_p)
1106 227978 : || (static_p == best_static_p
1107 227978 : && (best_insn_pseudos_num > insn_pseudos_num
1108 221162 : || (best_insn_pseudos_num == insn_pseudos_num
1109 199012 : && (bad_spills_num < smallest_bad_spills_num
1110 199012 : || (bad_spills_num == smallest_bad_spills_num
1111 199012 : && best_cost > cost))))))
1112 : {
1113 93064 : best_insn_pseudos_num = insn_pseudos_num;
1114 93064 : smallest_bad_spills_num = bad_spills_num;
1115 93064 : best_static_p = static_p;
1116 93064 : best_cost = cost;
1117 93064 : best_hard_regno = hard_regno;
1118 93064 : bitmap_copy (&best_spill_pseudos_bitmap, &spill_pseudos_bitmap);
1119 93064 : if (lra_dump_file != NULL)
1120 0 : fprintf (lra_dump_file,
1121 : " Now best %d(cost=%d, bad_spills=%d, insn_pseudos=%d)\n",
1122 : hard_regno, cost, bad_spills_num, insn_pseudos_num);
1123 : }
1124 276476 : assign_temporarily (regno, -1);
1125 2153641 : for (j = 0; j < n; j++)
1126 : {
1127 1600689 : reload_regno = sorted_reload_pseudos[j];
1128 1600689 : if (live_pseudos_reg_renumber[reload_regno] >= 0)
1129 750024 : assign_temporarily (reload_regno, -1);
1130 : }
1131 : }
1132 357482 : if (lra_dump_file != NULL)
1133 0 : fprintf (lra_dump_file, "\n");
1134 : /* Restore the live hard reg pseudo info for spilled pseudos. */
1135 648387 : EXECUTE_IF_SET_IN_BITMAP (&spill_pseudos_bitmap, 0, spill_regno, bi)
1136 290905 : update_lives (spill_regno, false);
1137 357482 : fail:
1138 373240 : ;
1139 : }
1140 : /* Spill: */
1141 104375 : EXECUTE_IF_SET_IN_BITMAP (&best_spill_pseudos_bitmap, 0, spill_regno, bi)
1142 : {
1143 49027 : if ((int) spill_regno >= lra_constraint_new_regno_start)
1144 4429 : former_reload_pseudo_spill_p = true;
1145 49027 : if (lra_dump_file != NULL)
1146 0 : fprintf (lra_dump_file, " Spill %sr%d(hr=%d, freq=%d) for r%d\n",
1147 : pseudo_prefix_title (spill_regno),
1148 0 : spill_regno, reg_renumber[spill_regno],
1149 0 : lra_reg_info[spill_regno].freq, regno);
1150 49027 : update_lives (spill_regno, true);
1151 49027 : lra_setup_reg_renumber (spill_regno, -1, false);
1152 : }
1153 55348 : bitmap_ior_into (spilled_pseudo_bitmap, &best_spill_pseudos_bitmap);
1154 55348 : return best_hard_regno;
1155 : }
1156 :
1157 : /* Assign HARD_REGNO to REGNO. */
1158 : static void
1159 6637871 : assign_hard_regno (int hard_regno, int regno)
1160 : {
1161 6637871 : int i;
1162 :
1163 6637871 : lra_assert (hard_regno >= 0);
1164 6637871 : lra_setup_reg_renumber (regno, hard_regno, true);
1165 6637871 : update_lives (regno, false);
1166 13473964 : for (i = 0;
1167 13473964 : i < hard_regno_nregs (hard_regno, lra_reg_info[regno].biggest_mode);
1168 : i++)
1169 6836093 : df_set_regs_ever_live (hard_regno + i, true);
1170 6637871 : }
1171 :
1172 : /* Array used for sorting different pseudos. */
1173 : static int *sorted_pseudos;
1174 :
1175 : /* The constraints pass is allowed to create equivalences between
1176 : pseudos that make the current allocation "incorrect" (in the sense
1177 : that pseudos are assigned to hard registers from their own conflict
1178 : sets). The global variable check_and_force_assignment_correctness_p says
1179 : whether this might have happened.
1180 :
1181 : Process pseudos assigned to hard registers (less frequently used
1182 : first), spill if a conflict is found, and mark the spilled pseudos
1183 : in SPILLED_PSEUDO_BITMAP. Set up LIVE_HARD_REG_PSEUDOS from
1184 : pseudos, assigned to hard registers. */
1185 : static void
1186 1579332 : setup_live_pseudos_and_spill_after_risky_transforms (bitmap
1187 : spilled_pseudo_bitmap)
1188 : {
1189 1579332 : int p, i, j, n, regno, hard_regno, biggest_nregs, nregs_diff;
1190 1579332 : unsigned int k, conflict_regno;
1191 1579332 : poly_int64 offset;
1192 1579332 : int val;
1193 1579332 : HARD_REG_SET conflict_set;
1194 1579332 : machine_mode mode, biggest_mode;
1195 1579332 : lra_live_range_t r;
1196 1579332 : bitmap_iterator bi;
1197 1579332 : int max_regno = max_reg_num ();
1198 :
1199 1579332 : if (! check_and_force_assignment_correctness_p)
1200 : {
1201 21160671 : for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)
1202 21103234 : if (reg_renumber[i] >= 0 && lra_reg_info[i].nrefs > 0)
1203 10135618 : update_lives (i, false);
1204 57437 : return;
1205 : }
1206 83252299 : for (n = 0, i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)
1207 81730404 : if ((pic_offset_table_rtx == NULL_RTX
1208 7563392 : || i != (int) REGNO (pic_offset_table_rtx))
1209 89244113 : && (hard_regno = reg_renumber[i]) >= 0 && lra_reg_info[i].nrefs > 0)
1210 : {
1211 31915361 : biggest_mode = lra_reg_info[i].biggest_mode;
1212 31915361 : biggest_nregs = hard_regno_nregs (hard_regno, biggest_mode);
1213 31915361 : nregs_diff = (biggest_nregs
1214 31915361 : - hard_regno_nregs (hard_regno, PSEUDO_REGNO_MODE (i)));
1215 31915361 : enum reg_class rclass = lra_get_allocno_class (i);
1216 :
1217 31915361 : if ((WORDS_BIG_ENDIAN
1218 : && (hard_regno - nregs_diff < 0
1219 : || !TEST_HARD_REG_BIT (reg_class_contents[rclass],
1220 : hard_regno - nregs_diff)))
1221 : || (!WORDS_BIG_ENDIAN
1222 31915361 : && (hard_regno + nregs_diff >= FIRST_PSEUDO_REGISTER
1223 31915361 : || !TEST_HARD_REG_BIT (reg_class_contents[rclass],
1224 : hard_regno + nregs_diff))))
1225 : {
1226 : /* Hard registers of paradoxical sub-registers are out of
1227 : range of pseudo register class. Spill the pseudo. */
1228 0 : reg_renumber[i] = -1;
1229 0 : continue;
1230 : }
1231 31915361 : sorted_pseudos[n++] = i;
1232 : }
1233 1521895 : qsort (sorted_pseudos, n, sizeof (int), pseudo_compare_func);
1234 1521895 : if (pic_offset_table_rtx != NULL_RTX
1235 49683 : && (regno = REGNO (pic_offset_table_rtx)) >= FIRST_PSEUDO_REGISTER
1236 1571578 : && reg_renumber[regno] >= 0 && lra_reg_info[regno].nrefs > 0)
1237 43484 : sorted_pseudos[n++] = regno;
1238 33480740 : for (i = n - 1; i >= 0; i--)
1239 : {
1240 31958845 : regno = sorted_pseudos[i];
1241 31958845 : hard_regno = reg_renumber[regno];
1242 31958845 : lra_assert (hard_regno >= 0);
1243 31958845 : mode = lra_reg_info[regno].biggest_mode;
1244 31958845 : sparseset_clear (live_range_hard_reg_pseudos);
1245 69461250 : for (r = lra_reg_info[regno].live_ranges; r != NULL; r = r->next)
1246 : {
1247 85809562 : EXECUTE_IF_SET_IN_BITMAP (&live_hard_reg_pseudos[r->start], 0, k, bi)
1248 48307157 : sparseset_set_bit (live_range_hard_reg_pseudos, k);
1249 277595121 : for (p = r->start + 1; p <= r->finish; p++)
1250 : {
1251 240092716 : lra_live_range_t r2;
1252 :
1253 240092716 : for (r2 = start_point_ranges[p];
1254 369409730 : r2 != NULL;
1255 129317014 : r2 = r2->start_next)
1256 129317014 : if (live_pseudos_reg_renumber[r2->regno] >= 0)
1257 69398274 : sparseset_set_bit (live_range_hard_reg_pseudos, r2->regno);
1258 : }
1259 : }
1260 31958845 : conflict_set = lra_no_alloc_regs;
1261 31958845 : conflict_set |= lra_reg_info[regno].conflict_hard_regs;
1262 31958845 : val = lra_reg_info[regno].val;
1263 31958845 : offset = lra_reg_info[regno].offset;
1264 129663575 : EXECUTE_IF_SET_IN_SPARSESET (live_range_hard_reg_pseudos, conflict_regno)
1265 97704730 : if (!lra_reg_val_equal_p (conflict_regno, val, offset)
1266 : /* If it is multi-register pseudos they should start on
1267 : the same hard register. */
1268 80653 : || hard_regno != reg_renumber[conflict_regno])
1269 : {
1270 97634992 : int conflict_hard_regno = reg_renumber[conflict_regno];
1271 :
1272 97634992 : biggest_mode = lra_reg_info[conflict_regno].biggest_mode;
1273 97634992 : biggest_nregs = hard_regno_nregs (conflict_hard_regno,
1274 : biggest_mode);
1275 97634992 : nregs_diff
1276 97634992 : = (biggest_nregs
1277 97634992 : - hard_regno_nregs (conflict_hard_regno,
1278 97634992 : PSEUDO_REGNO_MODE (conflict_regno)));
1279 97634992 : add_to_hard_reg_set (&conflict_set,
1280 : biggest_mode,
1281 : conflict_hard_regno
1282 : - (WORDS_BIG_ENDIAN ? nregs_diff : 0));
1283 : }
1284 31958845 : if (! overlaps_hard_reg_set_p (conflict_set, mode, hard_regno))
1285 : {
1286 31946816 : update_lives (regno, false);
1287 31946816 : continue;
1288 : }
1289 12029 : bitmap_set_bit (spilled_pseudo_bitmap, regno);
1290 12029 : for (j = 0;
1291 31804 : j < hard_regno_nregs (hard_regno, PSEUDO_REGNO_MODE (regno));
1292 : j++)
1293 19775 : lra_hard_reg_usage[hard_regno + j] -= lra_reg_info[regno].freq;
1294 12029 : reg_renumber[regno] = -1;
1295 12029 : if (regno >= lra_constraint_new_regno_start)
1296 1 : former_reload_pseudo_spill_p = true;
1297 12029 : if (lra_dump_file != NULL)
1298 0 : fprintf (lra_dump_file, " Spill r%d after risky transformations\n",
1299 : regno);
1300 : }
1301 : }
1302 :
1303 : /* Improve allocation by assigning the same hard regno of inheritance
1304 : pseudos to the connected pseudos. We need this because inheritance
1305 : pseudos are allocated after reload pseudos in the thread and when
1306 : we assign a hard register to a reload pseudo we don't know yet that
1307 : the connected inheritance pseudos can get the same hard register.
1308 : Add pseudos with changed allocation to bitmap CHANGED_PSEUDOS. */
1309 : static void
1310 1579332 : improve_inheritance (bitmap changed_pseudos)
1311 : {
1312 1579332 : unsigned int k;
1313 1579332 : int regno, another_regno, hard_regno, another_hard_regno, cost, i, n;
1314 1579332 : lra_copy_t cp, next_cp;
1315 1579332 : bitmap_iterator bi;
1316 :
1317 1579332 : if (lra_inheritance_iter > LRA_MAX_INHERITANCE_PASSES)
1318 5357 : return;
1319 1573975 : n = 0;
1320 3493636 : EXECUTE_IF_SET_IN_BITMAP (&lra_inheritance_pseudos, 0, k, bi)
1321 1919661 : if (reg_renumber[k] >= 0 && lra_reg_info[k].nrefs != 0)
1322 1274435 : sorted_pseudos[n++] = k;
1323 1573975 : qsort (sorted_pseudos, n, sizeof (int), pseudo_compare_func);
1324 4422385 : for (i = 0; i < n; i++)
1325 : {
1326 1274435 : regno = sorted_pseudos[i];
1327 1274435 : hard_regno = reg_renumber[regno];
1328 1274435 : lra_assert (hard_regno >= 0);
1329 3683199 : for (cp = lra_reg_info[regno].copies; cp != NULL; cp = next_cp)
1330 : {
1331 2408764 : if (cp->regno1 == regno)
1332 : {
1333 412943 : next_cp = cp->regno1_next;
1334 412943 : another_regno = cp->regno2;
1335 : }
1336 1995821 : else if (cp->regno2 == regno)
1337 : {
1338 1995821 : next_cp = cp->regno2_next;
1339 1995821 : another_regno = cp->regno1;
1340 : }
1341 : else
1342 0 : gcc_unreachable ();
1343 : /* Don't change reload pseudo allocation. It might have
1344 : this allocation for a purpose and changing it can result
1345 : in LRA cycling. */
1346 2408764 : if ((another_regno < lra_constraint_new_regno_start
1347 2408764 : || bitmap_bit_p (&lra_inheritance_pseudos, another_regno))
1348 849502 : && (another_hard_regno = reg_renumber[another_regno]) >= 0
1349 3138148 : && another_hard_regno != hard_regno)
1350 : {
1351 71765 : if (lra_dump_file != NULL)
1352 0 : fprintf
1353 0 : (lra_dump_file,
1354 : " Improving inheritance for %d(%d) and %d(%d)...\n",
1355 : regno, hard_regno, another_regno, another_hard_regno);
1356 71765 : update_lives (another_regno, true);
1357 71765 : lra_setup_reg_renumber (another_regno, -1, false);
1358 71765 : if (hard_regno == find_hard_regno_for (another_regno, &cost,
1359 : hard_regno, false))
1360 37266 : assign_hard_regno (hard_regno, another_regno);
1361 : else
1362 34499 : assign_hard_regno (another_hard_regno, another_regno);
1363 71765 : bitmap_set_bit (changed_pseudos, another_regno);
1364 : }
1365 : }
1366 : }
1367 : }
1368 :
1369 :
1370 : /* Bitmap finally containing all pseudos spilled on this assignment
1371 : pass. */
1372 : static bitmap_head all_spilled_pseudos;
1373 : /* All pseudos whose allocation was changed. */
1374 : static bitmap_head changed_pseudo_bitmap;
1375 :
1376 :
1377 : /* Add to LIVE_RANGE_HARD_REG_PSEUDOS all pseudos conflicting with
1378 : REGNO and whose hard regs can be assigned to REGNO. */
1379 : static void
1380 3522 : find_all_spills_for (int regno)
1381 : {
1382 3522 : int p;
1383 3522 : lra_live_range_t r;
1384 3522 : unsigned int k;
1385 3522 : bitmap_iterator bi;
1386 3522 : enum reg_class rclass;
1387 3522 : bool *rclass_intersect_p;
1388 :
1389 3522 : rclass = regno_allocno_class_array[regno];
1390 3522 : rclass_intersect_p = ira_reg_classes_intersect_p[rclass];
1391 9373 : for (r = lra_reg_info[regno].live_ranges; r != NULL; r = r->next)
1392 : {
1393 17346 : EXECUTE_IF_SET_IN_BITMAP (&live_hard_reg_pseudos[r->start], 0, k, bi)
1394 11495 : if (rclass_intersect_p[regno_allocno_class_array[k]])
1395 11338 : sparseset_set_bit (live_range_hard_reg_pseudos, k);
1396 12605 : for (p = r->start + 1; p <= r->finish; p++)
1397 : {
1398 6754 : lra_live_range_t r2;
1399 :
1400 6754 : for (r2 = start_point_ranges[p];
1401 16422 : r2 != NULL;
1402 9668 : r2 = r2->start_next)
1403 : {
1404 9668 : if (live_pseudos_reg_renumber[r2->regno] >= 0
1405 9600 : && ! sparseset_bit_p (live_range_hard_reg_pseudos, r2->regno)
1406 19251 : && rclass_intersect_p[regno_allocno_class_array[r2->regno]])
1407 9577 : sparseset_set_bit (live_range_hard_reg_pseudos, r2->regno);
1408 : }
1409 : }
1410 : }
1411 3522 : }
1412 :
1413 : /* Assign hard registers to reload pseudos and other pseudos. Return
1414 : true if we was not able to assign hard registers to all reload
1415 : pseudos. */
1416 : static bool
1417 1579332 : assign_by_spills (void)
1418 : {
1419 1579332 : int i, n, nfails, iter, regno, regno2, hard_regno, cost;
1420 1579332 : rtx restore_rtx;
1421 1579332 : bitmap_head changed_insns, do_not_assign_nonreload_pseudos;
1422 1579332 : unsigned int u, conflict_regno;
1423 1579332 : bitmap_iterator bi;
1424 1579332 : bool reload_p, fails_p = false;
1425 1579332 : int max_regno = max_reg_num ();
1426 :
1427 13812299 : for (n = 0, i = lra_constraint_new_regno_start; i < max_regno; i++)
1428 12232967 : if (reg_renumber[i] < 0 && lra_reg_info[i].nrefs != 0
1429 7884149 : && regno_allocno_class_array[i] != NO_REGS)
1430 6921929 : sorted_pseudos[n++] = i;
1431 1579332 : bitmap_initialize (&insn_conflict_pseudos, ®_obstack);
1432 1579332 : bitmap_initialize (&spill_pseudos_bitmap, ®_obstack);
1433 1579332 : bitmap_initialize (&best_spill_pseudos_bitmap, ®_obstack);
1434 1579332 : update_hard_regno_preference_check = XCNEWVEC (int, max_regno);
1435 1579332 : curr_update_hard_regno_preference_check = 0;
1436 1579332 : memset (try_hard_reg_pseudos_check, 0, sizeof (try_hard_reg_pseudos_check));
1437 150036540 : for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
1438 148457208 : bitmap_initialize (&try_hard_reg_pseudos[i], ®_obstack);
1439 1579332 : curr_pseudo_check = 0;
1440 1579332 : bitmap_initialize (&changed_insns, ®_obstack);
1441 1579332 : bitmap_initialize (&non_reload_pseudos, ®_obstack);
1442 1579332 : bitmap_ior (&non_reload_pseudos, &lra_inheritance_pseudos, &lra_split_regs);
1443 1579332 : bitmap_ior_into (&non_reload_pseudos, &lra_subreg_reload_pseudos);
1444 1579332 : bitmap_ior_into (&non_reload_pseudos, &lra_optional_reload_pseudos);
1445 1579332 : for (iter = 0; iter <= 1; iter++)
1446 : {
1447 1581876 : qsort (sorted_pseudos, n, sizeof (int), reload_pseudo_compare_func);
1448 1581876 : nfails = 0;
1449 10094601 : for (i = 0; i < n; i++)
1450 : {
1451 6930849 : regno = sorted_pseudos[i];
1452 6930849 : if (reg_renumber[regno] >= 0)
1453 1494 : continue;
1454 6929355 : if (lra_dump_file != NULL)
1455 192 : fprintf (lra_dump_file, " Assigning to %d "
1456 : "(cl=%s, orig=%d, freq=%d, tfirst=%d, tfreq=%d)...\n",
1457 96 : regno, reg_class_names[regno_allocno_class_array[regno]],
1458 96 : ORIGINAL_REGNO (regno_reg_rtx[regno]),
1459 96 : lra_reg_info[regno].freq, regno_assign_info[regno].first,
1460 96 : regno_assign_info[regno_assign_info[regno].first].freq);
1461 6929355 : hard_regno = find_hard_regno_for (regno, &cost, -1, iter == 1);
1462 6929355 : reload_p = ! bitmap_bit_p (&non_reload_pseudos, regno);
1463 6929355 : if (hard_regno < 0 && reload_p)
1464 55348 : hard_regno = spill_for (regno, &all_spilled_pseudos, iter == 1);
1465 6929355 : if (hard_regno < 0)
1466 : {
1467 490645 : if (reload_p)
1468 : {
1469 : /* Put unassigned reload pseudo first in the array. */
1470 6850 : regno2 = sorted_pseudos[nfails];
1471 6850 : sorted_pseudos[nfails++] = regno;
1472 6850 : sorted_pseudos[i] = regno2;
1473 : }
1474 : else
1475 : {
1476 : /* Consider all alternatives on the next constraint
1477 : subpass. */
1478 483795 : bitmap_set_bit (&all_spilled_pseudos, regno);
1479 : }
1480 : }
1481 : else
1482 : {
1483 : /* This register might have been spilled by the previous
1484 : pass. Indicate that it is no longer spilled. */
1485 6438710 : bitmap_clear_bit (&all_spilled_pseudos, regno);
1486 6438710 : assign_hard_regno (hard_regno, regno);
1487 6438710 : if (! reload_p || regno_allocno_class_array[regno] == ALL_REGS)
1488 : /* As non-reload pseudo assignment is changed we should
1489 : reconsider insns referring for the pseudo. Do the same if a
1490 : reload pseudo did not refine its class which can happens
1491 : when the pseudo occurs only in reload insns. */
1492 1392184 : bitmap_set_bit (&changed_pseudo_bitmap, regno);
1493 : }
1494 : }
1495 1581876 : if (nfails == 0 || iter > 0)
1496 : {
1497 1579332 : fails_p = nfails != 0;
1498 1579332 : break;
1499 : }
1500 : /* This is a very rare event. We cannot assign a hard register
1501 : to reload pseudo because the hard register was assigned to
1502 : another reload pseudo on a previous assignment pass. For x86
1503 : example, on the 1st pass we assigned CX (although another
1504 : hard register could be used for this) to reload pseudo in an
1505 : insn, on the 2nd pass we need CX (and only this) hard
1506 : register for a new reload pseudo in the same insn. Another
1507 : possible situation may occur in assigning to multi-regs
1508 : reload pseudos when hard regs pool is too fragmented even
1509 : after spilling non-reload pseudos.
1510 :
1511 : We should do something radical here to succeed. Here we
1512 : spill *all* conflicting pseudos and reassign them. */
1513 2544 : if (lra_dump_file != NULL)
1514 0 : fprintf (lra_dump_file, " 2nd iter for reload pseudo assignments:\n");
1515 2544 : sparseset_clear (live_range_hard_reg_pseudos);
1516 6066 : for (i = 0; i < nfails; i++)
1517 : {
1518 3522 : if (lra_dump_file != NULL)
1519 0 : fprintf (lra_dump_file, " Reload r%d assignment failure\n",
1520 0 : sorted_pseudos[i]);
1521 3522 : find_all_spills_for (sorted_pseudos[i]);
1522 : }
1523 25678 : EXECUTE_IF_SET_IN_SPARSESET (live_range_hard_reg_pseudos, conflict_regno)
1524 : {
1525 11567 : if ((int) conflict_regno >= lra_constraint_new_regno_start)
1526 : {
1527 1745 : sorted_pseudos[nfails++] = conflict_regno;
1528 1745 : former_reload_pseudo_spill_p = true;
1529 : }
1530 : else
1531 : /* It is better to do reloads before spilling as after the
1532 : spill-subpass we will reload memory instead of pseudos
1533 : and this will make reusing reload pseudos more
1534 : complicated. Going directly to the spill pass in such
1535 : case might result in worse code performance or even LRA
1536 : cycling if we have few registers. */
1537 9822 : bitmap_set_bit (&all_spilled_pseudos, conflict_regno);
1538 11567 : if (lra_dump_file != NULL)
1539 0 : fprintf (lra_dump_file, " Spill %s r%d(hr=%d, freq=%d)\n",
1540 : pseudo_prefix_title (conflict_regno), conflict_regno,
1541 0 : reg_renumber[conflict_regno],
1542 0 : lra_reg_info[conflict_regno].freq);
1543 11567 : update_lives (conflict_regno, true);
1544 11567 : lra_setup_reg_renumber (conflict_regno, -1, false);
1545 : }
1546 2544 : if (n < nfails)
1547 : n = nfails;
1548 : }
1549 1579332 : improve_inheritance (&changed_pseudo_bitmap);
1550 1579332 : bitmap_clear (&non_reload_pseudos);
1551 1579332 : bitmap_clear (&changed_insns);
1552 1579332 : if (! lra_simple_p)
1553 : {
1554 : /* We should not assign to original pseudos of inheritance
1555 : pseudos or split pseudos if any its inheritance pseudo did
1556 : not get hard register or any its split pseudo was not split
1557 : because undo inheritance/split pass will extend live range of
1558 : such inheritance or split pseudos. */
1559 1579326 : bitmap_initialize (&do_not_assign_nonreload_pseudos, ®_obstack);
1560 3685143 : EXECUTE_IF_SET_IN_BITMAP (&lra_inheritance_pseudos, 0, u, bi)
1561 2105817 : if ((restore_rtx = lra_reg_info[u].restore_rtx) != NULL_RTX
1562 1212969 : && REG_P (restore_rtx)
1563 1187636 : && reg_renumber[u] < 0
1564 2561864 : && bitmap_bit_p (&lra_inheritance_pseudos, u))
1565 456047 : bitmap_set_bit (&do_not_assign_nonreload_pseudos, REGNO (restore_rtx));
1566 2560616 : EXECUTE_IF_SET_IN_BITMAP (&lra_split_regs, 0, u, bi)
1567 981290 : if ((restore_rtx = lra_reg_info[u].restore_rtx) != NULL_RTX
1568 981290 : && reg_renumber[u] >= 0)
1569 : {
1570 1018 : lra_assert (REG_P (restore_rtx));
1571 1018 : bitmap_set_bit (&do_not_assign_nonreload_pseudos, REGNO (restore_rtx));
1572 : }
1573 104182051 : for (n = 0, i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)
1574 102602725 : if (((i < lra_constraint_new_regno_start
1575 90373602 : && ! bitmap_bit_p (&do_not_assign_nonreload_pseudos, i))
1576 12536961 : || (bitmap_bit_p (&lra_inheritance_pseudos, i)
1577 2105817 : && lra_reg_info[i].restore_rtx != NULL_RTX)
1578 11323992 : || (bitmap_bit_p (&lra_split_regs, i)
1579 981290 : && lra_reg_info[i].restore_rtx != NULL_RTX)
1580 10648026 : || bitmap_bit_p (&lra_subreg_reload_pseudos, i)
1581 10647567 : || bitmap_bit_p (&lra_optional_reload_pseudos, i))
1582 93085633 : && reg_renumber[i] < 0 && lra_reg_info[i].nrefs != 0
1583 105040357 : && regno_allocno_class_array[i] != NO_REGS)
1584 1723366 : sorted_pseudos[n++] = i;
1585 1579326 : bitmap_clear (&do_not_assign_nonreload_pseudos);
1586 1579326 : if (n != 0 && lra_dump_file != NULL)
1587 1 : fprintf (lra_dump_file, " Reassigning non-reload pseudos\n");
1588 1579326 : qsort (sorted_pseudos, n, sizeof (int), pseudo_compare_func);
1589 4882018 : for (i = 0; i < n; i++)
1590 : {
1591 1723366 : regno = sorted_pseudos[i];
1592 1723366 : hard_regno = find_hard_regno_for (regno, &cost, -1, false);
1593 1723366 : if (hard_regno >= 0)
1594 : {
1595 127396 : assign_hard_regno (hard_regno, regno);
1596 : /* We change allocation for non-reload pseudo on this
1597 : iteration -- mark the pseudo for invalidation of used
1598 : alternatives of insns containing the pseudo. */
1599 127396 : bitmap_set_bit (&changed_pseudo_bitmap, regno);
1600 : }
1601 : else
1602 : {
1603 1595970 : enum reg_class rclass = lra_get_allocno_class (regno);
1604 1595970 : enum reg_class spill_class;
1605 :
1606 3191940 : if (targetm.spill_class == NULL
1607 1595970 : || lra_reg_info[regno].restore_rtx == NULL_RTX
1608 466692 : || ! bitmap_bit_p (&lra_inheritance_pseudos, regno)
1609 1595970 : || (spill_class
1610 450540 : = ((enum reg_class)
1611 450540 : targetm.spill_class
1612 450540 : ((reg_class_t) rclass,
1613 450540 : PSEUDO_REGNO_MODE (regno)))) == NO_REGS)
1614 1595970 : continue;
1615 0 : regno_allocno_class_array[regno] = spill_class;
1616 0 : hard_regno = find_hard_regno_for (regno, &cost, -1, false);
1617 0 : if (hard_regno < 0)
1618 0 : regno_allocno_class_array[regno] = rclass;
1619 : else
1620 : {
1621 0 : setup_reg_classes
1622 0 : (regno, spill_class, spill_class, spill_class);
1623 0 : assign_hard_regno (hard_regno, regno);
1624 0 : bitmap_set_bit (&changed_pseudo_bitmap, regno);
1625 : }
1626 : }
1627 : }
1628 : }
1629 1579332 : free (update_hard_regno_preference_check);
1630 1579332 : bitmap_clear (&best_spill_pseudos_bitmap);
1631 1579332 : bitmap_clear (&spill_pseudos_bitmap);
1632 1579332 : bitmap_clear (&insn_conflict_pseudos);
1633 1579332 : return fails_p;
1634 : }
1635 :
1636 : /* Entry function to assign hard registers to new reload pseudos
1637 : starting with LRA_CONSTRAINT_NEW_REGNO_START (by possible spilling
1638 : of old pseudos) and possibly to the old pseudos. The function adds
1639 : what insns to process for the next constraint pass. Those are all
1640 : insns who contains non-reload and non-inheritance pseudos with
1641 : changed allocation.
1642 :
1643 : Return true if we did not spill any non-reload and non-inheritance
1644 : pseudos. Set up FAILS_P if we failed to assign hard registers to
1645 : all reload pseudos. */
1646 : bool
1647 1579332 : lra_assign (bool &fails_p)
1648 : {
1649 1579332 : int i;
1650 1579332 : unsigned int u;
1651 1579332 : bitmap_iterator bi;
1652 1579332 : bitmap_head insns_to_process;
1653 1579332 : bool no_spills_p;
1654 1579332 : int max_regno = max_reg_num ();
1655 :
1656 1579332 : timevar_push (TV_LRA_ASSIGN);
1657 1579332 : lra_assignment_iter++;
1658 1579332 : if (lra_dump_file != NULL)
1659 96 : fprintf (lra_dump_file, "\n********** Assignment #%d: **********\n\n",
1660 : lra_assignment_iter);
1661 1579332 : init_lives ();
1662 1579332 : sorted_pseudos = XNEWVEC (int, max_regno);
1663 1579332 : sorted_reload_pseudos = XNEWVEC (int, max_regno);
1664 1579332 : regno_allocno_class_array = XNEWVEC (enum reg_class, max_regno);
1665 1579332 : regno_live_length = XNEWVEC (int, max_regno);
1666 104412970 : for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)
1667 : {
1668 102833638 : int l;
1669 102833638 : lra_live_range_t r;
1670 :
1671 102833638 : regno_allocno_class_array[i] = lra_get_allocno_class (i);
1672 163931458 : for (l = 0, r = lra_reg_info[i].live_ranges; r != NULL; r = r->next)
1673 61097820 : l += r->finish - r->start + 1;
1674 102833638 : regno_live_length[i] = l;
1675 : }
1676 1579332 : former_reload_pseudo_spill_p = false;
1677 1579332 : init_regno_assign_info ();
1678 1579332 : bitmap_initialize (&all_spilled_pseudos, ®_obstack);
1679 1579332 : create_live_range_start_chains ();
1680 1579332 : setup_live_pseudos_and_spill_after_risky_transforms (&all_spilled_pseudos);
1681 1579332 : if (! lra_hard_reg_split_p && ! lra_asm_error_p && flag_checking)
1682 : /* Check correctness of allocation but only when there are no hard reg
1683 : splits and asm errors as in the case of errors explicit insns involving
1684 : hard regs are added or the asm is removed and this can result in
1685 : incorrect allocation. */
1686 103334026 : for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)
1687 101757065 : if (lra_reg_info[i].nrefs != 0
1688 50767879 : && reg_renumber[i] >= 0
1689 101757065 : && overlaps_hard_reg_set_p (lra_reg_info[i].conflict_hard_regs,
1690 41561767 : PSEUDO_REGNO_MODE (i), reg_renumber[i]))
1691 0 : gcc_unreachable ();
1692 : /* Setup insns to process on the next constraint pass. */
1693 1579332 : bitmap_initialize (&changed_pseudo_bitmap, ®_obstack);
1694 1579332 : init_live_reload_and_inheritance_pseudos ();
1695 1579332 : fails_p = assign_by_spills ();
1696 1579332 : finish_live_reload_and_inheritance_pseudos ();
1697 1579332 : bitmap_ior_into (&changed_pseudo_bitmap, &all_spilled_pseudos);
1698 1579332 : no_spills_p = true;
1699 1858928 : EXECUTE_IF_SET_IN_BITMAP (&all_spilled_pseudos, 0, u, bi)
1700 : /* We ignore spilled pseudos created on last inheritance pass
1701 : because they will be removed. */
1702 309002 : if (lra_reg_info[u].restore_rtx == NULL_RTX)
1703 : {
1704 : no_spills_p = false;
1705 : break;
1706 : }
1707 1579332 : finish_live_range_start_chains ();
1708 1579332 : bitmap_clear (&all_spilled_pseudos);
1709 1579332 : bitmap_initialize (&insns_to_process, ®_obstack);
1710 3613981 : EXECUTE_IF_SET_IN_BITMAP (&changed_pseudo_bitmap, 0, u, bi)
1711 2034649 : bitmap_ior_into (&insns_to_process, &lra_reg_info[u].insn_bitmap);
1712 1579332 : bitmap_clear (&changed_pseudo_bitmap);
1713 6464816 : EXECUTE_IF_SET_IN_BITMAP (&insns_to_process, 0, u, bi)
1714 : {
1715 4885484 : lra_push_insn_by_uid (u);
1716 : /* Invalidate alternatives for insn should be processed. */
1717 4885484 : lra_set_used_insn_alternative_by_uid (u, -1);
1718 : }
1719 1579332 : bitmap_clear (&insns_to_process);
1720 1579332 : finish_regno_assign_info ();
1721 1579332 : free (regno_live_length);
1722 1579332 : free (regno_allocno_class_array);
1723 1579332 : free (sorted_pseudos);
1724 1579332 : free (sorted_reload_pseudos);
1725 1579332 : finish_lives ();
1726 1579332 : timevar_pop (TV_LRA_ASSIGN);
1727 1579332 : if (former_reload_pseudo_spill_p)
1728 1944 : lra_assignment_iter_after_spill++;
1729 : /* This is conditional on flag_checking because valid code can take
1730 : more than this maximum number of iteration, but at the same time
1731 : the test can uncover errors in machine descriptions. */
1732 1579332 : if (flag_checking
1733 1579312 : && (lra_assignment_iter_after_spill
1734 1579312 : > LRA_MAX_ASSIGNMENT_ITERATION_NUMBER))
1735 0 : internal_error
1736 0 : ("maximum number of LRA assignment passes is achieved (%d)",
1737 : LRA_MAX_ASSIGNMENT_ITERATION_NUMBER);
1738 : /* Reset the assignment correctness flag: */
1739 1579332 : check_and_force_assignment_correctness_p = false;
1740 1579332 : return no_spills_p;
1741 : }
1742 :
1743 : /* Find start and finish insns for reload pseudo REGNO. Return true
1744 : if we managed to find the expected insns. Return false,
1745 : otherwise. */
1746 : static bool
1747 3328 : find_reload_regno_insns (int regno, rtx_insn * &start, rtx_insn * &finish)
1748 : {
1749 3328 : unsigned int uid;
1750 3328 : bitmap_iterator bi;
1751 3328 : int insns_num = 0;
1752 3328 : bool clobber_p = false;
1753 3328 : rtx_insn *prev_insn, *next_insn;
1754 3328 : rtx_insn *start_insn = NULL, *first_insn = NULL, *second_insn = NULL;
1755 :
1756 12107 : EXECUTE_IF_SET_IN_BITMAP (&lra_reg_info[regno].insn_bitmap, 0, uid, bi)
1757 : {
1758 8779 : if (start_insn == NULL)
1759 3328 : start_insn = lra_insn_recog_data[uid]->insn;
1760 8779 : if (GET_CODE (PATTERN (lra_insn_recog_data[uid]->insn)) == CLOBBER)
1761 : clobber_p = true;
1762 : else
1763 8779 : insns_num++;
1764 : }
1765 : /* For reload pseudo we should have at most 3 insns besides clobber referring for
1766 : it: input/output reload insns and the original insn. */
1767 3328 : if (insns_num > 3)
1768 : return false;
1769 3328 : if (clobber_p)
1770 0 : insns_num++;
1771 3328 : if (insns_num > 1)
1772 : {
1773 3104 : for (prev_insn = PREV_INSN (start_insn),
1774 3104 : next_insn = NEXT_INSN (start_insn);
1775 222413 : insns_num != 1 && (prev_insn != NULL
1776 2328 : || (next_insn != NULL && second_insn == NULL)); )
1777 : {
1778 : if (prev_insn != NULL)
1779 : {
1780 219309 : if (bitmap_bit_p (&lra_reg_info[regno].insn_bitmap,
1781 219309 : INSN_UID (prev_insn)))
1782 : {
1783 590 : first_insn = prev_insn;
1784 590 : insns_num--;
1785 : }
1786 219309 : prev_insn = PREV_INSN (prev_insn);
1787 : }
1788 219309 : if (next_insn != NULL && second_insn == NULL)
1789 : {
1790 5477 : if (! bitmap_bit_p (&lra_reg_info[regno].insn_bitmap,
1791 5477 : INSN_UID (next_insn)))
1792 2944 : next_insn = NEXT_INSN (next_insn);
1793 : else
1794 : {
1795 2533 : second_insn = next_insn;
1796 2533 : insns_num--;
1797 : }
1798 : }
1799 : }
1800 3104 : if (insns_num > 1)
1801 : return false;
1802 : }
1803 776 : start = first_insn != NULL ? first_insn : start_insn;
1804 1000 : finish = second_insn != NULL ? second_insn : start_insn;
1805 1000 : return true;
1806 : }
1807 :
1808 : /* Process reload pseudos which did not get a hard reg, split a hard reg live
1809 : range in live range of a reload pseudo, and then return TRUE. Otherwise,
1810 : return FALSE. When FAIL_P is TRUE and if we did not split a hard reg live
1811 : range for failed reload pseudos, report an error and modify related asm
1812 : insns. */
1813 : bool
1814 2488 : lra_split_hard_reg_for (bool fail_p)
1815 : {
1816 2488 : int i, regno;
1817 2488 : rtx_insn *insn, *first, *last;
1818 2488 : unsigned int u;
1819 2488 : bitmap_iterator bi;
1820 2488 : enum reg_class rclass;
1821 2488 : int max_regno = max_reg_num ();
1822 : /* We did not assign hard regs to reload pseudos after two
1823 : iterations. Either it's an asm and something is wrong with the
1824 : constraints, or we have run out of spill registers; error out in
1825 : either case. */
1826 2488 : bool asm_p = false, spill_p = false;
1827 2488 : bitmap_head failed_reload_insns, failed_reload_pseudos, over_split_insns;
1828 :
1829 2488 : if (lra_dump_file != NULL)
1830 0 : fprintf (lra_dump_file,
1831 : "\n****** Splitting a hard reg after assignment #%d: ******\n\n",
1832 : lra_assignment_iter);
1833 2488 : bitmap_initialize (&failed_reload_pseudos, ®_obstack);
1834 2488 : bitmap_initialize (&non_reload_pseudos, ®_obstack);
1835 2488 : bitmap_ior (&non_reload_pseudos, &lra_inheritance_pseudos, &lra_split_regs);
1836 2488 : bitmap_ior_into (&non_reload_pseudos, &lra_subreg_reload_pseudos);
1837 2488 : bitmap_ior_into (&non_reload_pseudos, &lra_optional_reload_pseudos);
1838 2488 : bitmap_initialize (&over_split_insns, ®_obstack);
1839 2488 : update_hard_regno_preference_check = XCNEWVEC (int, max_regno);
1840 2488 : curr_update_hard_regno_preference_check = 0;
1841 17308 : for (i = lra_constraint_new_regno_start; i < max_regno; i++)
1842 6247 : if (reg_renumber[i] < 0 && lra_reg_info[i].nrefs != 0
1843 5422 : && (rclass = lra_get_allocno_class (i)) != NO_REGS
1844 20237 : && ! bitmap_bit_p (&non_reload_pseudos, i))
1845 : {
1846 3328 : if (! find_reload_regno_insns (i, first, last))
1847 2328 : continue;
1848 1000 : if (BLOCK_FOR_INSN (first) == BLOCK_FOR_INSN (last))
1849 : {
1850 : /* Check that we are not trying to split over the same insn
1851 : requiring reloads to avoid splitting the same hard reg twice or
1852 : more. If we need several hard regs splitting over the same insn
1853 : it can be finished on the next iterations.
1854 :
1855 : The following loop iteration number is small as we split hard
1856 : reg in a very small range. */
1857 1826 : for (insn = first;
1858 2826 : insn != NEXT_INSN (last);
1859 1826 : insn = NEXT_INSN (insn))
1860 1835 : if (bitmap_bit_p (&over_split_insns, INSN_UID (insn)))
1861 : break;
1862 1000 : if (insn != NEXT_INSN (last)
1863 1000 : || !spill_hard_reg_in_range (i, rclass, first, last))
1864 : {
1865 839 : bitmap_set_bit (&failed_reload_pseudos, i);
1866 : }
1867 : else
1868 : {
1869 306 : for (insn = first;
1870 467 : insn != NEXT_INSN (last);
1871 306 : insn = NEXT_INSN (insn))
1872 306 : bitmap_set_bit (&over_split_insns, INSN_UID (insn));
1873 : spill_p = true;
1874 : }
1875 : }
1876 : }
1877 2488 : bitmap_clear (&over_split_insns);
1878 2488 : bitmap_clear (&non_reload_pseudos);
1879 2488 : if (spill_p)
1880 : {
1881 100 : lra_dump_insns_if_possible ("changed func after splitting hard regs");
1882 : }
1883 : else
1884 : {
1885 2388 : bitmap_initialize (&failed_reload_insns, ®_obstack);
1886 3218 : EXECUTE_IF_SET_IN_BITMAP (&failed_reload_pseudos, 0, u, bi)
1887 : {
1888 830 : regno = u;
1889 830 : bitmap_ior_into (&failed_reload_insns,
1890 830 : &lra_reg_info[regno].insn_bitmap);
1891 830 : if (fail_p)
1892 53 : lra_setup_reg_renumber
1893 106 : (regno, ira_class_hard_regs[lra_get_allocno_class (regno)][0],
1894 : false);
1895 : }
1896 2388 : if (fail_p)
1897 287 : EXECUTE_IF_SET_IN_BITMAP (&failed_reload_insns, 0, u, bi)
1898 : {
1899 92 : insn = lra_insn_recog_data[u]->insn;
1900 92 : if (asm_noperands (PATTERN (insn)) >= 0)
1901 : {
1902 53 : asm_p = true;
1903 53 : lra_asm_insn_error (insn);
1904 : }
1905 39 : else if (!asm_p)
1906 : {
1907 0 : error ("unable to find a register to spill");
1908 0 : fatal_insn ("this is the insn:", insn);
1909 : }
1910 : }
1911 2388 : bitmap_clear (&failed_reload_insns);
1912 : }
1913 2488 : free (update_hard_regno_preference_check);
1914 2488 : bitmap_clear (&failed_reload_pseudos);
1915 2488 : return spill_p;
1916 : }
|