comparison gcc/lcm.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents f6334be47118
children 84e7813d76e9
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 /* Generic partial redundancy elimination with lazy code motion support. 1 /* Generic partial redundancy elimination with lazy code motion support.
2 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2 Copyright (C) 1998-2017 Free Software Foundation, Inc.
3 2010, 2011 Free Software Foundation, Inc.
4 3
5 This file is part of GCC. 4 This file is part of GCC.
6 5
7 GCC is free software; you can redistribute it and/or modify it under 6 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 7 the terms of the GNU General Public License as published by the Free
50 49
51 50
52 #include "config.h" 51 #include "config.h"
53 #include "system.h" 52 #include "system.h"
54 #include "coretypes.h" 53 #include "coretypes.h"
55 #include "tm.h" 54 #include "backend.h"
56 #include "rtl.h" 55 #include "cfganal.h"
57 #include "regs.h" 56 #include "lcm.h"
58 #include "hard-reg-set.h"
59 #include "flags.h"
60 #include "insn-config.h"
61 #include "recog.h"
62 #include "basic-block.h"
63 #include "output.h"
64 #include "tm_p.h"
65 #include "function.h"
66 #include "sbitmap.h"
67
68 /* We want target macros for the mode switching code to be able to refer
69 to instruction attribute values. */
70 #include "insn-attr.h"
71 57
72 /* Edge based LCM routines. */ 58 /* Edge based LCM routines. */
73 static void compute_antinout_edge (sbitmap *, sbitmap *, sbitmap *, sbitmap *); 59 static void compute_antinout_edge (sbitmap *, sbitmap *, sbitmap *, sbitmap *);
74 static void compute_earliest (struct edge_list *, int, sbitmap *, sbitmap *, 60 static void compute_earliest (struct edge_list *, int, sbitmap *, sbitmap *,
75 sbitmap *, sbitmap *, sbitmap *); 61 sbitmap *, sbitmap *, sbitmap *);
104 edge_iterator ei; 90 edge_iterator ei;
105 91
106 /* Allocate a worklist array/queue. Entries are only added to the 92 /* Allocate a worklist array/queue. Entries are only added to the
107 list if they were not already on the list. So the size is 93 list if they were not already on the list. So the size is
108 bounded by the number of basic blocks. */ 94 bounded by the number of basic blocks. */
109 qin = qout = worklist = XNEWVEC (basic_block, n_basic_blocks); 95 qin = qout = worklist = XNEWVEC (basic_block, n_basic_blocks_for_fn (cfun));
110 96
111 /* We want a maximal solution, so make an optimistic initialization of 97 /* We want a maximal solution, so make an optimistic initialization of
112 ANTIN. */ 98 ANTIN. */
113 sbitmap_vector_ones (antin, last_basic_block); 99 bitmap_vector_ones (antin, last_basic_block_for_fn (cfun));
114 100
115 /* Put every block on the worklist; this is necessary because of the 101 /* Put every block on the worklist; this is necessary because of the
116 optimistic initialization of ANTIN above. */ 102 optimistic initialization of ANTIN above. */
117 FOR_EACH_BB_REVERSE (bb) 103 int *postorder = XNEWVEC (int, n_basic_blocks_for_fn (cfun));
118 { 104 int postorder_num = post_order_compute (postorder, false, false);
105 for (int i = 0; i < postorder_num; ++i)
106 {
107 bb = BASIC_BLOCK_FOR_FN (cfun, postorder[i]);
119 *qin++ = bb; 108 *qin++ = bb;
120 bb->aux = bb; 109 bb->aux = bb;
121 } 110 }
111 free (postorder);
122 112
123 qin = worklist; 113 qin = worklist;
124 qend = &worklist[n_basic_blocks - NUM_FIXED_BLOCKS]; 114 qend = &worklist[n_basic_blocks_for_fn (cfun) - NUM_FIXED_BLOCKS];
125 qlen = n_basic_blocks - NUM_FIXED_BLOCKS; 115 qlen = n_basic_blocks_for_fn (cfun) - NUM_FIXED_BLOCKS;
126 116
127 /* Mark blocks which are predecessors of the exit block so that we 117 /* Mark blocks which are predecessors of the exit block so that we
128 can easily identify them below. */ 118 can easily identify them below. */
129 FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds) 119 FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR_FOR_FN (cfun)->preds)
130 e->src->aux = EXIT_BLOCK_PTR; 120 e->src->aux = EXIT_BLOCK_PTR_FOR_FN (cfun);
131 121
132 /* Iterate until the worklist is empty. */ 122 /* Iterate until the worklist is empty. */
133 while (qlen) 123 while (qlen)
134 { 124 {
135 /* Take the first entry off the worklist. */ 125 /* Take the first entry off the worklist. */
137 qlen--; 127 qlen--;
138 128
139 if (qout >= qend) 129 if (qout >= qend)
140 qout = worklist; 130 qout = worklist;
141 131
142 if (bb->aux == EXIT_BLOCK_PTR) 132 if (bb->aux == EXIT_BLOCK_PTR_FOR_FN (cfun))
143 /* Do not clear the aux field for blocks which are predecessors of 133 /* Do not clear the aux field for blocks which are predecessors of
144 the EXIT block. That way we never add then to the worklist 134 the EXIT block. That way we never add then to the worklist
145 again. */ 135 again. */
146 sbitmap_zero (antout[bb->index]); 136 bitmap_clear (antout[bb->index]);
147 else 137 else
148 { 138 {
149 /* Clear the aux field of this block so that it can be added to 139 /* Clear the aux field of this block so that it can be added to
150 the worklist again if necessary. */ 140 the worklist again if necessary. */
151 bb->aux = NULL; 141 bb->aux = NULL;
152 sbitmap_intersection_of_succs (antout[bb->index], antin, bb->index); 142 bitmap_intersection_of_succs (antout[bb->index], antin, bb);
153 } 143 }
154 144
155 if (sbitmap_a_or_b_and_c_cg (antin[bb->index], antloc[bb->index], 145 if (bitmap_or_and (antin[bb->index], antloc[bb->index],
156 transp[bb->index], antout[bb->index])) 146 transp[bb->index], antout[bb->index]))
157 /* If the in state of this block changed, then we need 147 /* If the in state of this block changed, then we need
158 to add the predecessors of this block to the worklist 148 to add the predecessors of this block to the worklist
159 if they are not already on the worklist. */ 149 if they are not already on the worklist. */
160 FOR_EACH_EDGE (e, ei, bb->preds) 150 FOR_EACH_EDGE (e, ei, bb->preds)
161 if (!e->src->aux && e->src != ENTRY_BLOCK_PTR) 151 if (!e->src->aux && e->src != ENTRY_BLOCK_PTR_FOR_FN (cfun))
162 { 152 {
163 *qin++ = e->src; 153 *qin++ = e->src;
164 e->src->aux = e; 154 e->src->aux = e;
165 qlen++; 155 qlen++;
166 if (qin >= qend) 156 if (qin >= qend)
178 static void 168 static void
179 compute_earliest (struct edge_list *edge_list, int n_exprs, sbitmap *antin, 169 compute_earliest (struct edge_list *edge_list, int n_exprs, sbitmap *antin,
180 sbitmap *antout, sbitmap *avout, sbitmap *kill, 170 sbitmap *antout, sbitmap *avout, sbitmap *kill,
181 sbitmap *earliest) 171 sbitmap *earliest)
182 { 172 {
183 sbitmap difference, temp_bitmap;
184 int x, num_edges; 173 int x, num_edges;
185 basic_block pred, succ; 174 basic_block pred, succ;
186 175
187 num_edges = NUM_EDGES (edge_list); 176 num_edges = NUM_EDGES (edge_list);
188 177
189 difference = sbitmap_alloc (n_exprs); 178 auto_sbitmap difference (n_exprs), temp_bitmap (n_exprs);
190 temp_bitmap = sbitmap_alloc (n_exprs);
191
192 for (x = 0; x < num_edges; x++) 179 for (x = 0; x < num_edges; x++)
193 { 180 {
194 pred = INDEX_EDGE_PRED_BB (edge_list, x); 181 pred = INDEX_EDGE_PRED_BB (edge_list, x);
195 succ = INDEX_EDGE_SUCC_BB (edge_list, x); 182 succ = INDEX_EDGE_SUCC_BB (edge_list, x);
196 if (pred == ENTRY_BLOCK_PTR) 183 if (pred == ENTRY_BLOCK_PTR_FOR_FN (cfun))
197 sbitmap_copy (earliest[x], antin[succ->index]); 184 bitmap_copy (earliest[x], antin[succ->index]);
198 else 185 else
199 { 186 {
200 if (succ == EXIT_BLOCK_PTR) 187 if (succ == EXIT_BLOCK_PTR_FOR_FN (cfun))
201 sbitmap_zero (earliest[x]); 188 bitmap_clear (earliest[x]);
202 else 189 else
203 { 190 {
204 sbitmap_difference (difference, antin[succ->index], 191 bitmap_and_compl (difference, antin[succ->index],
205 avout[pred->index]); 192 avout[pred->index]);
206 sbitmap_not (temp_bitmap, antout[pred->index]); 193 bitmap_not (temp_bitmap, antout[pred->index]);
207 sbitmap_a_and_b_or_c (earliest[x], difference, 194 bitmap_and_or (earliest[x], difference,
208 kill[pred->index], temp_bitmap); 195 kill[pred->index], temp_bitmap);
209 } 196 }
210 } 197 }
211 } 198 }
212
213 sbitmap_free (temp_bitmap);
214 sbitmap_free (difference);
215 } 199 }
216 200
217 /* later(p,s) is dependent on the calculation of laterin(p). 201 /* later(p,s) is dependent on the calculation of laterin(p).
218 laterin(p) is dependent on the calculation of later(p2,p). 202 laterin(p) is dependent on the calculation of later(p2,p).
219 203
257 241
258 /* Allocate a worklist array/queue. Entries are only added to the 242 /* Allocate a worklist array/queue. Entries are only added to the
259 list if they were not already on the list. So the size is 243 list if they were not already on the list. So the size is
260 bounded by the number of basic blocks. */ 244 bounded by the number of basic blocks. */
261 qin = qout = worklist 245 qin = qout = worklist
262 = XNEWVEC (basic_block, n_basic_blocks); 246 = XNEWVEC (basic_block, n_basic_blocks_for_fn (cfun));
263 247
264 /* Initialize a mapping from each edge to its index. */ 248 /* Initialize a mapping from each edge to its index. */
265 for (i = 0; i < num_edges; i++) 249 for (i = 0; i < num_edges; i++)
266 INDEX_EDGE (edge_list, i)->aux = (void *) (size_t) i; 250 INDEX_EDGE (edge_list, i)->aux = (void *) (size_t) i;
267 251
273 257
274 If the optimistic setting of LATER on that edge was incorrect (for 258 If the optimistic setting of LATER on that edge was incorrect (for
275 example the expression is ANTLOC in a block within the loop) then 259 example the expression is ANTLOC in a block within the loop) then
276 this algorithm will detect it when we process the block at the head 260 this algorithm will detect it when we process the block at the head
277 of the optimistic edge. That will requeue the affected blocks. */ 261 of the optimistic edge. That will requeue the affected blocks. */
278 sbitmap_vector_ones (later, num_edges); 262 bitmap_vector_ones (later, num_edges);
279 263
280 /* Note that even though we want an optimistic setting of LATER, we 264 /* Note that even though we want an optimistic setting of LATER, we
281 do not want to be overly optimistic. Consider an outgoing edge from 265 do not want to be overly optimistic. Consider an outgoing edge from
282 the entry block. That edge should always have a LATER value the 266 the entry block. That edge should always have a LATER value the
283 same as EARLIEST for that edge. */ 267 same as EARLIEST for that edge. */
284 FOR_EACH_EDGE (e, ei, ENTRY_BLOCK_PTR->succs) 268 FOR_EACH_EDGE (e, ei, ENTRY_BLOCK_PTR_FOR_FN (cfun)->succs)
285 sbitmap_copy (later[(size_t) e->aux], earliest[(size_t) e->aux]); 269 bitmap_copy (later[(size_t) e->aux], earliest[(size_t) e->aux]);
286 270
287 /* Add all the blocks to the worklist. This prevents an early exit from 271 /* Add all the blocks to the worklist. This prevents an early exit from
288 the loop given our optimistic initialization of LATER above. */ 272 the loop given our optimistic initialization of LATER above. */
289 FOR_EACH_BB (bb) 273 auto_vec<int, 20> postorder;
290 { 274 inverted_post_order_compute (&postorder);
275 for (unsigned int i = 0; i < postorder.length (); ++i)
276 {
277 bb = BASIC_BLOCK_FOR_FN (cfun, postorder[i]);
278 if (bb == EXIT_BLOCK_PTR_FOR_FN (cfun)
279 || bb == ENTRY_BLOCK_PTR_FOR_FN (cfun))
280 continue;
291 *qin++ = bb; 281 *qin++ = bb;
292 bb->aux = bb; 282 bb->aux = bb;
293 } 283 }
294 284
295 /* Note that we do not use the last allocated element for our queue, 285 /* Note that we do not use the last allocated element for our queue,
296 as EXIT_BLOCK is never inserted into it. */ 286 as EXIT_BLOCK is never inserted into it. */
297 qin = worklist; 287 qin = worklist;
298 qend = &worklist[n_basic_blocks - NUM_FIXED_BLOCKS]; 288 qend = &worklist[n_basic_blocks_for_fn (cfun) - NUM_FIXED_BLOCKS];
299 qlen = n_basic_blocks - NUM_FIXED_BLOCKS; 289 qlen = n_basic_blocks_for_fn (cfun) - NUM_FIXED_BLOCKS;
300 290
301 /* Iterate until the worklist is empty. */ 291 /* Iterate until the worklist is empty. */
302 while (qlen) 292 while (qlen)
303 { 293 {
304 /* Take the first entry off the worklist. */ 294 /* Take the first entry off the worklist. */
307 qlen--; 297 qlen--;
308 if (qout >= qend) 298 if (qout >= qend)
309 qout = worklist; 299 qout = worklist;
310 300
311 /* Compute the intersection of LATERIN for each incoming edge to B. */ 301 /* Compute the intersection of LATERIN for each incoming edge to B. */
312 sbitmap_ones (laterin[bb->index]); 302 bitmap_ones (laterin[bb->index]);
313 FOR_EACH_EDGE (e, ei, bb->preds) 303 FOR_EACH_EDGE (e, ei, bb->preds)
314 sbitmap_a_and_b (laterin[bb->index], laterin[bb->index], 304 bitmap_and (laterin[bb->index], laterin[bb->index],
315 later[(size_t)e->aux]); 305 later[(size_t)e->aux]);
316 306
317 /* Calculate LATER for all outgoing edges. */ 307 /* Calculate LATER for all outgoing edges. */
318 FOR_EACH_EDGE (e, ei, bb->succs) 308 FOR_EACH_EDGE (e, ei, bb->succs)
319 if (sbitmap_union_of_diff_cg (later[(size_t) e->aux], 309 if (bitmap_ior_and_compl (later[(size_t) e->aux],
320 earliest[(size_t) e->aux], 310 earliest[(size_t) e->aux],
321 laterin[e->src->index], 311 laterin[bb->index],
322 antloc[e->src->index]) 312 antloc[bb->index])
323 /* If LATER for an outgoing edge was changed, then we need 313 /* If LATER for an outgoing edge was changed, then we need
324 to add the target of the outgoing edge to the worklist. */ 314 to add the target of the outgoing edge to the worklist. */
325 && e->dest != EXIT_BLOCK_PTR && e->dest->aux == 0) 315 && e->dest != EXIT_BLOCK_PTR_FOR_FN (cfun) && e->dest->aux == 0)
326 { 316 {
327 *qin++ = e->dest; 317 *qin++ = e->dest;
328 e->dest->aux = e; 318 e->dest->aux = e;
329 qlen++; 319 qlen++;
330 if (qin >= qend) 320 if (qin >= qend)
333 } 323 }
334 324
335 /* Computation of insertion and deletion points requires computing LATERIN 325 /* Computation of insertion and deletion points requires computing LATERIN
336 for the EXIT block. We allocated an extra entry in the LATERIN array 326 for the EXIT block. We allocated an extra entry in the LATERIN array
337 for just this purpose. */ 327 for just this purpose. */
338 sbitmap_ones (laterin[last_basic_block]); 328 bitmap_ones (laterin[last_basic_block_for_fn (cfun)]);
339 FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds) 329 FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR_FOR_FN (cfun)->preds)
340 sbitmap_a_and_b (laterin[last_basic_block], 330 bitmap_and (laterin[last_basic_block_for_fn (cfun)],
341 laterin[last_basic_block], 331 laterin[last_basic_block_for_fn (cfun)],
342 later[(size_t) e->aux]); 332 later[(size_t) e->aux]);
343 333
344 clear_aux_for_edges (); 334 clear_aux_for_edges ();
345 free (worklist); 335 free (worklist);
346 } 336 }
347 337
353 sbitmap *del) 343 sbitmap *del)
354 { 344 {
355 int x; 345 int x;
356 basic_block bb; 346 basic_block bb;
357 347
358 FOR_EACH_BB (bb) 348 FOR_EACH_BB_FN (bb, cfun)
359 sbitmap_difference (del[bb->index], antloc[bb->index], 349 bitmap_and_compl (del[bb->index], antloc[bb->index],
360 laterin[bb->index]); 350 laterin[bb->index]);
361 351
362 for (x = 0; x < NUM_EDGES (edge_list); x++) 352 for (x = 0; x < NUM_EDGES (edge_list); x++)
363 { 353 {
364 basic_block b = INDEX_EDGE_SUCC_BB (edge_list, x); 354 basic_block b = INDEX_EDGE_SUCC_BB (edge_list, x);
365 355
366 if (b == EXIT_BLOCK_PTR) 356 if (b == EXIT_BLOCK_PTR_FOR_FN (cfun))
367 sbitmap_difference (insert[x], later[x], laterin[last_basic_block]); 357 bitmap_and_compl (insert[x], later[x],
358 laterin[last_basic_block_for_fn (cfun)]);
368 else 359 else
369 sbitmap_difference (insert[x], later[x], laterin[b->index]); 360 bitmap_and_compl (insert[x], later[x], laterin[b->index]);
370 } 361 }
371 } 362 }
372 363
373 /* Given local properties TRANSP, ANTLOC, AVOUT, KILL return the insert and 364 /* Given local properties TRANSP, ANTLOC, AVLOC, KILL return the insert and
374 delete vectors for edge based LCM. Returns an edgelist which is used to 365 delete vectors for edge based LCM and return the AVIN, AVOUT bitmap.
375 map the insert vector to what edge an expression should be inserted on. */ 366 map the insert vector to what edge an expression should be inserted on. */
367
368 struct edge_list *
369 pre_edge_lcm_avs (int n_exprs, sbitmap *transp,
370 sbitmap *avloc, sbitmap *antloc, sbitmap *kill,
371 sbitmap *avin, sbitmap *avout,
372 sbitmap **insert, sbitmap **del)
373 {
374 sbitmap *antin, *antout, *earliest;
375 sbitmap *later, *laterin;
376 struct edge_list *edge_list;
377 int num_edges;
378
379 edge_list = create_edge_list ();
380 num_edges = NUM_EDGES (edge_list);
381
382 #ifdef LCM_DEBUG_INFO
383 if (dump_file)
384 {
385 fprintf (dump_file, "Edge List:\n");
386 verify_edge_list (dump_file, edge_list);
387 print_edge_list (dump_file, edge_list);
388 dump_bitmap_vector (dump_file, "transp", "", transp,
389 last_basic_block_for_fn (cfun));
390 dump_bitmap_vector (dump_file, "antloc", "", antloc,
391 last_basic_block_for_fn (cfun));
392 dump_bitmap_vector (dump_file, "avloc", "", avloc,
393 last_basic_block_for_fn (cfun));
394 dump_bitmap_vector (dump_file, "kill", "", kill,
395 last_basic_block_for_fn (cfun));
396 }
397 #endif
398
399 /* Compute global availability. */
400 compute_available (avloc, kill, avout, avin);
401
402 /* Compute global anticipatability. */
403 antin = sbitmap_vector_alloc (last_basic_block_for_fn (cfun), n_exprs);
404 antout = sbitmap_vector_alloc (last_basic_block_for_fn (cfun), n_exprs);
405 compute_antinout_edge (antloc, transp, antin, antout);
406
407 #ifdef LCM_DEBUG_INFO
408 if (dump_file)
409 {
410 dump_bitmap_vector (dump_file, "antin", "", antin,
411 last_basic_block_for_fn (cfun));
412 dump_bitmap_vector (dump_file, "antout", "", antout,
413 last_basic_block_for_fn (cfun));
414 }
415 #endif
416
417 /* Compute earliestness. */
418 earliest = sbitmap_vector_alloc (num_edges, n_exprs);
419 compute_earliest (edge_list, n_exprs, antin, antout, avout, kill, earliest);
420
421 #ifdef LCM_DEBUG_INFO
422 if (dump_file)
423 dump_bitmap_vector (dump_file, "earliest", "", earliest, num_edges);
424 #endif
425
426 sbitmap_vector_free (antout);
427 sbitmap_vector_free (antin);
428
429 later = sbitmap_vector_alloc (num_edges, n_exprs);
430
431 /* Allocate an extra element for the exit block in the laterin vector. */
432 laterin = sbitmap_vector_alloc (last_basic_block_for_fn (cfun) + 1,
433 n_exprs);
434 compute_laterin (edge_list, earliest, antloc, later, laterin);
435
436 #ifdef LCM_DEBUG_INFO
437 if (dump_file)
438 {
439 dump_bitmap_vector (dump_file, "laterin", "", laterin,
440 last_basic_block_for_fn (cfun) + 1);
441 dump_bitmap_vector (dump_file, "later", "", later, num_edges);
442 }
443 #endif
444
445 sbitmap_vector_free (earliest);
446
447 *insert = sbitmap_vector_alloc (num_edges, n_exprs);
448 *del = sbitmap_vector_alloc (last_basic_block_for_fn (cfun), n_exprs);
449 bitmap_vector_clear (*insert, num_edges);
450 bitmap_vector_clear (*del, last_basic_block_for_fn (cfun));
451 compute_insert_delete (edge_list, antloc, later, laterin, *insert, *del);
452
453 sbitmap_vector_free (laterin);
454 sbitmap_vector_free (later);
455
456 #ifdef LCM_DEBUG_INFO
457 if (dump_file)
458 {
459 dump_bitmap_vector (dump_file, "pre_insert_map", "", *insert, num_edges);
460 dump_bitmap_vector (dump_file, "pre_delete_map", "", *del,
461 last_basic_block_for_fn (cfun));
462 }
463 #endif
464
465 return edge_list;
466 }
467
468 /* Wrapper to allocate avin/avout and call pre_edge_lcm_avs. */
376 469
377 struct edge_list * 470 struct edge_list *
378 pre_edge_lcm (int n_exprs, sbitmap *transp, 471 pre_edge_lcm (int n_exprs, sbitmap *transp,
379 sbitmap *avloc, sbitmap *antloc, sbitmap *kill, 472 sbitmap *avloc, sbitmap *antloc, sbitmap *kill,
380 sbitmap **insert, sbitmap **del) 473 sbitmap **insert, sbitmap **del)
381 { 474 {
382 sbitmap *antin, *antout, *earliest; 475 struct edge_list *edge_list;
383 sbitmap *avin, *avout; 476 sbitmap *avin, *avout;
384 sbitmap *later, *laterin; 477
385 struct edge_list *edge_list; 478 avin = sbitmap_vector_alloc (last_basic_block_for_fn (cfun), n_exprs);
386 int num_edges; 479 avout = sbitmap_vector_alloc (last_basic_block_for_fn (cfun), n_exprs);
387 480
388 edge_list = create_edge_list (); 481 edge_list = pre_edge_lcm_avs (n_exprs, transp, avloc, antloc, kill,
389 num_edges = NUM_EDGES (edge_list); 482 avin, avout, insert, del);
390 483
391 #ifdef LCM_DEBUG_INFO 484 sbitmap_vector_free (avout);
392 if (dump_file)
393 {
394 fprintf (dump_file, "Edge List:\n");
395 verify_edge_list (dump_file, edge_list);
396 print_edge_list (dump_file, edge_list);
397 dump_sbitmap_vector (dump_file, "transp", "", transp, last_basic_block);
398 dump_sbitmap_vector (dump_file, "antloc", "", antloc, last_basic_block);
399 dump_sbitmap_vector (dump_file, "avloc", "", avloc, last_basic_block);
400 dump_sbitmap_vector (dump_file, "kill", "", kill, last_basic_block);
401 }
402 #endif
403
404 /* Compute global availability. */
405 avin = sbitmap_vector_alloc (last_basic_block, n_exprs);
406 avout = sbitmap_vector_alloc (last_basic_block, n_exprs);
407 compute_available (avloc, kill, avout, avin);
408 sbitmap_vector_free (avin); 485 sbitmap_vector_free (avin);
409
410 /* Compute global anticipatability. */
411 antin = sbitmap_vector_alloc (last_basic_block, n_exprs);
412 antout = sbitmap_vector_alloc (last_basic_block, n_exprs);
413 compute_antinout_edge (antloc, transp, antin, antout);
414
415 #ifdef LCM_DEBUG_INFO
416 if (dump_file)
417 {
418 dump_sbitmap_vector (dump_file, "antin", "", antin, last_basic_block);
419 dump_sbitmap_vector (dump_file, "antout", "", antout, last_basic_block);
420 }
421 #endif
422
423 /* Compute earliestness. */
424 earliest = sbitmap_vector_alloc (num_edges, n_exprs);
425 compute_earliest (edge_list, n_exprs, antin, antout, avout, kill, earliest);
426
427 #ifdef LCM_DEBUG_INFO
428 if (dump_file)
429 dump_sbitmap_vector (dump_file, "earliest", "", earliest, num_edges);
430 #endif
431
432 sbitmap_vector_free (antout);
433 sbitmap_vector_free (antin);
434 sbitmap_vector_free (avout);
435
436 later = sbitmap_vector_alloc (num_edges, n_exprs);
437
438 /* Allocate an extra element for the exit block in the laterin vector. */
439 laterin = sbitmap_vector_alloc (last_basic_block + 1, n_exprs);
440 compute_laterin (edge_list, earliest, antloc, later, laterin);
441
442 #ifdef LCM_DEBUG_INFO
443 if (dump_file)
444 {
445 dump_sbitmap_vector (dump_file, "laterin", "", laterin, last_basic_block + 1);
446 dump_sbitmap_vector (dump_file, "later", "", later, num_edges);
447 }
448 #endif
449
450 sbitmap_vector_free (earliest);
451
452 *insert = sbitmap_vector_alloc (num_edges, n_exprs);
453 *del = sbitmap_vector_alloc (last_basic_block, n_exprs);
454 sbitmap_vector_zero (*insert, num_edges);
455 sbitmap_vector_zero (*del, last_basic_block);
456 compute_insert_delete (edge_list, antloc, later, laterin, *insert, *del);
457
458 sbitmap_vector_free (laterin);
459 sbitmap_vector_free (later);
460
461 #ifdef LCM_DEBUG_INFO
462 if (dump_file)
463 {
464 dump_sbitmap_vector (dump_file, "pre_insert_map", "", *insert, num_edges);
465 dump_sbitmap_vector (dump_file, "pre_delete_map", "", *del,
466 last_basic_block);
467 }
468 #endif
469 486
470 return edge_list; 487 return edge_list;
471 } 488 }
472 489
473 /* Compute the AVIN and AVOUT vectors from the AVLOC and KILL vectors. 490 /* Compute the AVIN and AVOUT vectors from the AVLOC and KILL vectors.
484 501
485 /* Allocate a worklist array/queue. Entries are only added to the 502 /* Allocate a worklist array/queue. Entries are only added to the
486 list if they were not already on the list. So the size is 503 list if they were not already on the list. So the size is
487 bounded by the number of basic blocks. */ 504 bounded by the number of basic blocks. */
488 qin = qout = worklist = 505 qin = qout = worklist =
489 XNEWVEC (basic_block, n_basic_blocks - NUM_FIXED_BLOCKS); 506 XNEWVEC (basic_block, n_basic_blocks_for_fn (cfun) - NUM_FIXED_BLOCKS);
490 507
491 /* We want a maximal solution. */ 508 /* We want a maximal solution. */
492 sbitmap_vector_ones (avout, last_basic_block); 509 bitmap_vector_ones (avout, last_basic_block_for_fn (cfun));
493 510
494 /* Put every block on the worklist; this is necessary because of the 511 /* Put every block on the worklist; this is necessary because of the
495 optimistic initialization of AVOUT above. */ 512 optimistic initialization of AVOUT above. Use inverted postorder
496 FOR_EACH_BB (bb) 513 to make the dataflow problem require less iterations. */
497 { 514 auto_vec<int, 20> postorder;
515 inverted_post_order_compute (&postorder);
516 for (unsigned int i = 0; i < postorder.length (); ++i)
517 {
518 bb = BASIC_BLOCK_FOR_FN (cfun, postorder[i]);
519 if (bb == EXIT_BLOCK_PTR_FOR_FN (cfun)
520 || bb == ENTRY_BLOCK_PTR_FOR_FN (cfun))
521 continue;
498 *qin++ = bb; 522 *qin++ = bb;
499 bb->aux = bb; 523 bb->aux = bb;
500 } 524 }
501 525
502 qin = worklist; 526 qin = worklist;
503 qend = &worklist[n_basic_blocks - NUM_FIXED_BLOCKS]; 527 qend = &worklist[n_basic_blocks_for_fn (cfun) - NUM_FIXED_BLOCKS];
504 qlen = n_basic_blocks - NUM_FIXED_BLOCKS; 528 qlen = n_basic_blocks_for_fn (cfun) - NUM_FIXED_BLOCKS;
505 529
506 /* Mark blocks which are successors of the entry block so that we 530 /* Mark blocks which are successors of the entry block so that we
507 can easily identify them below. */ 531 can easily identify them below. */
508 FOR_EACH_EDGE (e, ei, ENTRY_BLOCK_PTR->succs) 532 FOR_EACH_EDGE (e, ei, ENTRY_BLOCK_PTR_FOR_FN (cfun)->succs)
509 e->dest->aux = ENTRY_BLOCK_PTR; 533 e->dest->aux = ENTRY_BLOCK_PTR_FOR_FN (cfun);
510 534
511 /* Iterate until the worklist is empty. */ 535 /* Iterate until the worklist is empty. */
512 while (qlen) 536 while (qlen)
513 { 537 {
514 /* Take the first entry off the worklist. */ 538 /* Take the first entry off the worklist. */
519 qout = worklist; 543 qout = worklist;
520 544
521 /* If one of the predecessor blocks is the ENTRY block, then the 545 /* If one of the predecessor blocks is the ENTRY block, then the
522 intersection of avouts is the null set. We can identify such blocks 546 intersection of avouts is the null set. We can identify such blocks
523 by the special value in the AUX field in the block structure. */ 547 by the special value in the AUX field in the block structure. */
524 if (bb->aux == ENTRY_BLOCK_PTR) 548 if (bb->aux == ENTRY_BLOCK_PTR_FOR_FN (cfun))
525 /* Do not clear the aux field for blocks which are successors of the 549 /* Do not clear the aux field for blocks which are successors of the
526 ENTRY block. That way we never add then to the worklist again. */ 550 ENTRY block. That way we never add then to the worklist again. */
527 sbitmap_zero (avin[bb->index]); 551 bitmap_clear (avin[bb->index]);
528 else 552 else
529 { 553 {
530 /* Clear the aux field of this block so that it can be added to 554 /* Clear the aux field of this block so that it can be added to
531 the worklist again if necessary. */ 555 the worklist again if necessary. */
532 bb->aux = NULL; 556 bb->aux = NULL;
533 sbitmap_intersection_of_preds (avin[bb->index], avout, bb->index); 557 bitmap_intersection_of_preds (avin[bb->index], avout, bb);
534 } 558 }
535 559
536 if (sbitmap_union_of_diff_cg (avout[bb->index], avloc[bb->index], 560 if (bitmap_ior_and_compl (avout[bb->index], avloc[bb->index],
537 avin[bb->index], kill[bb->index])) 561 avin[bb->index], kill[bb->index]))
538 /* If the out state of this block changed, then we need 562 /* If the out state of this block changed, then we need
539 to add the successors of this block to the worklist 563 to add the successors of this block to the worklist
540 if they are not already on the worklist. */ 564 if they are not already on the worklist. */
541 FOR_EACH_EDGE (e, ei, bb->succs) 565 FOR_EACH_EDGE (e, ei, bb->succs)
542 if (!e->dest->aux && e->dest != EXIT_BLOCK_PTR) 566 if (!e->dest->aux && e->dest != EXIT_BLOCK_PTR_FOR_FN (cfun))
543 { 567 {
544 *qin++ = e->dest; 568 *qin++ = e->dest;
545 e->dest->aux = e; 569 e->dest->aux = e;
546 qlen++; 570 qlen++;
547 571
560 static void 584 static void
561 compute_farthest (struct edge_list *edge_list, int n_exprs, 585 compute_farthest (struct edge_list *edge_list, int n_exprs,
562 sbitmap *st_avout, sbitmap *st_avin, sbitmap *st_antin, 586 sbitmap *st_avout, sbitmap *st_avin, sbitmap *st_antin,
563 sbitmap *kill, sbitmap *farthest) 587 sbitmap *kill, sbitmap *farthest)
564 { 588 {
565 sbitmap difference, temp_bitmap;
566 int x, num_edges; 589 int x, num_edges;
567 basic_block pred, succ; 590 basic_block pred, succ;
568 591
569 num_edges = NUM_EDGES (edge_list); 592 num_edges = NUM_EDGES (edge_list);
570 593
571 difference = sbitmap_alloc (n_exprs); 594 auto_sbitmap difference (n_exprs), temp_bitmap (n_exprs);
572 temp_bitmap = sbitmap_alloc (n_exprs);
573
574 for (x = 0; x < num_edges; x++) 595 for (x = 0; x < num_edges; x++)
575 { 596 {
576 pred = INDEX_EDGE_PRED_BB (edge_list, x); 597 pred = INDEX_EDGE_PRED_BB (edge_list, x);
577 succ = INDEX_EDGE_SUCC_BB (edge_list, x); 598 succ = INDEX_EDGE_SUCC_BB (edge_list, x);
578 if (succ == EXIT_BLOCK_PTR) 599 if (succ == EXIT_BLOCK_PTR_FOR_FN (cfun))
579 sbitmap_copy (farthest[x], st_avout[pred->index]); 600 bitmap_copy (farthest[x], st_avout[pred->index]);
580 else 601 else
581 { 602 {
582 if (pred == ENTRY_BLOCK_PTR) 603 if (pred == ENTRY_BLOCK_PTR_FOR_FN (cfun))
583 sbitmap_zero (farthest[x]); 604 bitmap_clear (farthest[x]);
584 else 605 else
585 { 606 {
586 sbitmap_difference (difference, st_avout[pred->index], 607 bitmap_and_compl (difference, st_avout[pred->index],
587 st_antin[succ->index]); 608 st_antin[succ->index]);
588 sbitmap_not (temp_bitmap, st_avin[succ->index]); 609 bitmap_not (temp_bitmap, st_avin[succ->index]);
589 sbitmap_a_and_b_or_c (farthest[x], difference, 610 bitmap_and_or (farthest[x], difference,
590 kill[succ->index], temp_bitmap); 611 kill[succ->index], temp_bitmap);
591 } 612 }
592 } 613 }
593 } 614 }
594
595 sbitmap_free (temp_bitmap);
596 sbitmap_free (difference);
597 } 615 }
598 616
599 /* Compute nearer and nearerout vectors for edge based lcm. 617 /* Compute nearer and nearerout vectors for edge based lcm.
600 618
601 This is the mirror of compute_laterin, additional comments on the 619 This is the mirror of compute_laterin, additional comments on the
613 num_edges = NUM_EDGES (edge_list); 631 num_edges = NUM_EDGES (edge_list);
614 632
615 /* Allocate a worklist array/queue. Entries are only added to the 633 /* Allocate a worklist array/queue. Entries are only added to the
616 list if they were not already on the list. So the size is 634 list if they were not already on the list. So the size is
617 bounded by the number of basic blocks. */ 635 bounded by the number of basic blocks. */
618 tos = worklist = XNEWVEC (basic_block, n_basic_blocks + 1); 636 tos = worklist = XNEWVEC (basic_block, n_basic_blocks_for_fn (cfun) + 1);
619 637
620 /* Initialize NEARER for each edge and build a mapping from an edge to 638 /* Initialize NEARER for each edge and build a mapping from an edge to
621 its index. */ 639 its index. */
622 for (i = 0; i < num_edges; i++) 640 for (i = 0; i < num_edges; i++)
623 INDEX_EDGE (edge_list, i)->aux = (void *) (size_t) i; 641 INDEX_EDGE (edge_list, i)->aux = (void *) (size_t) i;
624 642
625 /* We want a maximal solution. */ 643 /* We want a maximal solution. */
626 sbitmap_vector_ones (nearer, num_edges); 644 bitmap_vector_ones (nearer, num_edges);
627 645
628 /* Note that even though we want an optimistic setting of NEARER, we 646 /* Note that even though we want an optimistic setting of NEARER, we
629 do not want to be overly optimistic. Consider an incoming edge to 647 do not want to be overly optimistic. Consider an incoming edge to
630 the exit block. That edge should always have a NEARER value the 648 the exit block. That edge should always have a NEARER value the
631 same as FARTHEST for that edge. */ 649 same as FARTHEST for that edge. */
632 FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds) 650 FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR_FOR_FN (cfun)->preds)
633 sbitmap_copy (nearer[(size_t)e->aux], farthest[(size_t)e->aux]); 651 bitmap_copy (nearer[(size_t)e->aux], farthest[(size_t)e->aux]);
634 652
635 /* Add all the blocks to the worklist. This prevents an early exit 653 /* Add all the blocks to the worklist. This prevents an early exit
636 from the loop given our optimistic initialization of NEARER. */ 654 from the loop given our optimistic initialization of NEARER. */
637 FOR_EACH_BB (bb) 655 FOR_EACH_BB_FN (bb, cfun)
638 { 656 {
639 *tos++ = bb; 657 *tos++ = bb;
640 bb->aux = bb; 658 bb->aux = bb;
641 } 659 }
642 660
646 /* Take the first entry off the worklist. */ 664 /* Take the first entry off the worklist. */
647 bb = *--tos; 665 bb = *--tos;
648 bb->aux = NULL; 666 bb->aux = NULL;
649 667
650 /* Compute the intersection of NEARER for each outgoing edge from B. */ 668 /* Compute the intersection of NEARER for each outgoing edge from B. */
651 sbitmap_ones (nearerout[bb->index]); 669 bitmap_ones (nearerout[bb->index]);
652 FOR_EACH_EDGE (e, ei, bb->succs) 670 FOR_EACH_EDGE (e, ei, bb->succs)
653 sbitmap_a_and_b (nearerout[bb->index], nearerout[bb->index], 671 bitmap_and (nearerout[bb->index], nearerout[bb->index],
654 nearer[(size_t) e->aux]); 672 nearer[(size_t) e->aux]);
655 673
656 /* Calculate NEARER for all incoming edges. */ 674 /* Calculate NEARER for all incoming edges. */
657 FOR_EACH_EDGE (e, ei, bb->preds) 675 FOR_EACH_EDGE (e, ei, bb->preds)
658 if (sbitmap_union_of_diff_cg (nearer[(size_t) e->aux], 676 if (bitmap_ior_and_compl (nearer[(size_t) e->aux],
659 farthest[(size_t) e->aux], 677 farthest[(size_t) e->aux],
660 nearerout[e->dest->index], 678 nearerout[e->dest->index],
661 st_avloc[e->dest->index]) 679 st_avloc[e->dest->index])
662 /* If NEARER for an incoming edge was changed, then we need 680 /* If NEARER for an incoming edge was changed, then we need
663 to add the source of the incoming edge to the worklist. */ 681 to add the source of the incoming edge to the worklist. */
664 && e->src != ENTRY_BLOCK_PTR && e->src->aux == 0) 682 && e->src != ENTRY_BLOCK_PTR_FOR_FN (cfun) && e->src->aux == 0)
665 { 683 {
666 *tos++ = e->src; 684 *tos++ = e->src;
667 e->src->aux = e; 685 e->src->aux = e;
668 } 686 }
669 } 687 }
670 688
671 /* Computation of insertion and deletion points requires computing NEAREROUT 689 /* Computation of insertion and deletion points requires computing NEAREROUT
672 for the ENTRY block. We allocated an extra entry in the NEAREROUT array 690 for the ENTRY block. We allocated an extra entry in the NEAREROUT array
673 for just this purpose. */ 691 for just this purpose. */
674 sbitmap_ones (nearerout[last_basic_block]); 692 bitmap_ones (nearerout[last_basic_block_for_fn (cfun)]);
675 FOR_EACH_EDGE (e, ei, ENTRY_BLOCK_PTR->succs) 693 FOR_EACH_EDGE (e, ei, ENTRY_BLOCK_PTR_FOR_FN (cfun)->succs)
676 sbitmap_a_and_b (nearerout[last_basic_block], 694 bitmap_and (nearerout[last_basic_block_for_fn (cfun)],
677 nearerout[last_basic_block], 695 nearerout[last_basic_block_for_fn (cfun)],
678 nearer[(size_t) e->aux]); 696 nearer[(size_t) e->aux]);
679 697
680 clear_aux_for_edges (); 698 clear_aux_for_edges ();
681 free (tos); 699 free (tos);
682 } 700 }
689 sbitmap *insert, sbitmap *del) 707 sbitmap *insert, sbitmap *del)
690 { 708 {
691 int x; 709 int x;
692 basic_block bb; 710 basic_block bb;
693 711
694 FOR_EACH_BB (bb) 712 FOR_EACH_BB_FN (bb, cfun)
695 sbitmap_difference (del[bb->index], st_avloc[bb->index], 713 bitmap_and_compl (del[bb->index], st_avloc[bb->index],
696 nearerout[bb->index]); 714 nearerout[bb->index]);
697 715
698 for (x = 0; x < NUM_EDGES (edge_list); x++) 716 for (x = 0; x < NUM_EDGES (edge_list); x++)
699 { 717 {
700 basic_block b = INDEX_EDGE_PRED_BB (edge_list, x); 718 basic_block b = INDEX_EDGE_PRED_BB (edge_list, x);
701 if (b == ENTRY_BLOCK_PTR) 719 if (b == ENTRY_BLOCK_PTR_FOR_FN (cfun))
702 sbitmap_difference (insert[x], nearer[x], nearerout[last_basic_block]); 720 bitmap_and_compl (insert[x], nearer[x],
721 nearerout[last_basic_block_for_fn (cfun)]);
703 else 722 else
704 sbitmap_difference (insert[x], nearer[x], nearerout[b->index]); 723 bitmap_and_compl (insert[x], nearer[x], nearerout[b->index]);
705 } 724 }
706 } 725 }
707 726
708 /* Given local properties TRANSP, ST_AVLOC, ST_ANTLOC, KILL return the 727 /* Given local properties TRANSP, ST_AVLOC, ST_ANTLOC, KILL return the
709 insert and delete vectors for edge based reverse LCM. Returns an 728 insert and delete vectors for edge based reverse LCM. Returns an
722 int num_edges; 741 int num_edges;
723 742
724 edge_list = create_edge_list (); 743 edge_list = create_edge_list ();
725 num_edges = NUM_EDGES (edge_list); 744 num_edges = NUM_EDGES (edge_list);
726 745
727 st_antin = sbitmap_vector_alloc (last_basic_block, n_exprs); 746 st_antin = sbitmap_vector_alloc (last_basic_block_for_fn (cfun), n_exprs);
728 st_antout = sbitmap_vector_alloc (last_basic_block, n_exprs); 747 st_antout = sbitmap_vector_alloc (last_basic_block_for_fn (cfun), n_exprs);
729 sbitmap_vector_zero (st_antin, last_basic_block); 748 bitmap_vector_clear (st_antin, last_basic_block_for_fn (cfun));
730 sbitmap_vector_zero (st_antout, last_basic_block); 749 bitmap_vector_clear (st_antout, last_basic_block_for_fn (cfun));
731 compute_antinout_edge (st_antloc, transp, st_antin, st_antout); 750 compute_antinout_edge (st_antloc, transp, st_antin, st_antout);
732 751
733 /* Compute global anticipatability. */ 752 /* Compute global anticipatability. */
734 st_avout = sbitmap_vector_alloc (last_basic_block, n_exprs); 753 st_avout = sbitmap_vector_alloc (last_basic_block_for_fn (cfun), n_exprs);
735 st_avin = sbitmap_vector_alloc (last_basic_block, n_exprs); 754 st_avin = sbitmap_vector_alloc (last_basic_block_for_fn (cfun), n_exprs);
736 compute_available (st_avloc, kill, st_avout, st_avin); 755 compute_available (st_avloc, kill, st_avout, st_avin);
737 756
738 #ifdef LCM_DEBUG_INFO 757 #ifdef LCM_DEBUG_INFO
739 if (dump_file) 758 if (dump_file)
740 { 759 {
741 fprintf (dump_file, "Edge List:\n"); 760 fprintf (dump_file, "Edge List:\n");
742 verify_edge_list (dump_file, edge_list); 761 verify_edge_list (dump_file, edge_list);
743 print_edge_list (dump_file, edge_list); 762 print_edge_list (dump_file, edge_list);
744 dump_sbitmap_vector (dump_file, "transp", "", transp, last_basic_block); 763 dump_bitmap_vector (dump_file, "transp", "", transp,
745 dump_sbitmap_vector (dump_file, "st_avloc", "", st_avloc, last_basic_block); 764 last_basic_block_for_fn (cfun));
746 dump_sbitmap_vector (dump_file, "st_antloc", "", st_antloc, last_basic_block); 765 dump_bitmap_vector (dump_file, "st_avloc", "", st_avloc,
747 dump_sbitmap_vector (dump_file, "st_antin", "", st_antin, last_basic_block); 766 last_basic_block_for_fn (cfun));
748 dump_sbitmap_vector (dump_file, "st_antout", "", st_antout, last_basic_block); 767 dump_bitmap_vector (dump_file, "st_antloc", "", st_antloc,
749 dump_sbitmap_vector (dump_file, "st_kill", "", kill, last_basic_block); 768 last_basic_block_for_fn (cfun));
750 } 769 dump_bitmap_vector (dump_file, "st_antin", "", st_antin,
751 #endif 770 last_basic_block_for_fn (cfun));
752 771 dump_bitmap_vector (dump_file, "st_antout", "", st_antout,
753 #ifdef LCM_DEBUG_INFO 772 last_basic_block_for_fn (cfun));
754 if (dump_file) 773 dump_bitmap_vector (dump_file, "st_kill", "", kill,
755 { 774 last_basic_block_for_fn (cfun));
756 dump_sbitmap_vector (dump_file, "st_avout", "", st_avout, last_basic_block); 775 }
757 dump_sbitmap_vector (dump_file, "st_avin", "", st_avin, last_basic_block); 776 #endif
777
778 #ifdef LCM_DEBUG_INFO
779 if (dump_file)
780 {
781 dump_bitmap_vector (dump_file, "st_avout", "", st_avout, last_basic_block_for_fn (cfun));
782 dump_bitmap_vector (dump_file, "st_avin", "", st_avin, last_basic_block_for_fn (cfun));
758 } 783 }
759 #endif 784 #endif
760 785
761 /* Compute farthestness. */ 786 /* Compute farthestness. */
762 farthest = sbitmap_vector_alloc (num_edges, n_exprs); 787 farthest = sbitmap_vector_alloc (num_edges, n_exprs);
763 compute_farthest (edge_list, n_exprs, st_avout, st_avin, st_antin, 788 compute_farthest (edge_list, n_exprs, st_avout, st_avin, st_antin,
764 kill, farthest); 789 kill, farthest);
765 790
766 #ifdef LCM_DEBUG_INFO 791 #ifdef LCM_DEBUG_INFO
767 if (dump_file) 792 if (dump_file)
768 dump_sbitmap_vector (dump_file, "farthest", "", farthest, num_edges); 793 dump_bitmap_vector (dump_file, "farthest", "", farthest, num_edges);
769 #endif 794 #endif
770 795
771 sbitmap_vector_free (st_antin); 796 sbitmap_vector_free (st_antin);
772 sbitmap_vector_free (st_antout); 797 sbitmap_vector_free (st_antout);
773 798
775 sbitmap_vector_free (st_avout); 800 sbitmap_vector_free (st_avout);
776 801
777 nearer = sbitmap_vector_alloc (num_edges, n_exprs); 802 nearer = sbitmap_vector_alloc (num_edges, n_exprs);
778 803
779 /* Allocate an extra element for the entry block. */ 804 /* Allocate an extra element for the entry block. */
780 nearerout = sbitmap_vector_alloc (last_basic_block + 1, n_exprs); 805 nearerout = sbitmap_vector_alloc (last_basic_block_for_fn (cfun) + 1,
806 n_exprs);
781 compute_nearerout (edge_list, farthest, st_avloc, nearer, nearerout); 807 compute_nearerout (edge_list, farthest, st_avloc, nearer, nearerout);
782 808
783 #ifdef LCM_DEBUG_INFO 809 #ifdef LCM_DEBUG_INFO
784 if (dump_file) 810 if (dump_file)
785 { 811 {
786 dump_sbitmap_vector (dump_file, "nearerout", "", nearerout, 812 dump_bitmap_vector (dump_file, "nearerout", "", nearerout,
787 last_basic_block + 1); 813 last_basic_block_for_fn (cfun) + 1);
788 dump_sbitmap_vector (dump_file, "nearer", "", nearer, num_edges); 814 dump_bitmap_vector (dump_file, "nearer", "", nearer, num_edges);
789 } 815 }
790 #endif 816 #endif
791 817
792 sbitmap_vector_free (farthest); 818 sbitmap_vector_free (farthest);
793 819
794 *insert = sbitmap_vector_alloc (num_edges, n_exprs); 820 *insert = sbitmap_vector_alloc (num_edges, n_exprs);
795 *del = sbitmap_vector_alloc (last_basic_block, n_exprs); 821 *del = sbitmap_vector_alloc (last_basic_block_for_fn (cfun), n_exprs);
796 compute_rev_insert_delete (edge_list, st_avloc, nearer, nearerout, 822 compute_rev_insert_delete (edge_list, st_avloc, nearer, nearerout,
797 *insert, *del); 823 *insert, *del);
798 824
799 sbitmap_vector_free (nearerout); 825 sbitmap_vector_free (nearerout);
800 sbitmap_vector_free (nearer); 826 sbitmap_vector_free (nearer);
801 827
802 #ifdef LCM_DEBUG_INFO 828 #ifdef LCM_DEBUG_INFO
803 if (dump_file) 829 if (dump_file)
804 { 830 {
805 dump_sbitmap_vector (dump_file, "pre_insert_map", "", *insert, num_edges); 831 dump_bitmap_vector (dump_file, "pre_insert_map", "", *insert, num_edges);
806 dump_sbitmap_vector (dump_file, "pre_delete_map", "", *del, 832 dump_bitmap_vector (dump_file, "pre_delete_map", "", *del,
807 last_basic_block); 833 last_basic_block_for_fn (cfun));
808 } 834 }
809 #endif 835 #endif
810 return edge_list; 836 return edge_list;
811 } 837 }
812 838