comparison gcc/cfgloopanal.c @ 14:f6334be47118

update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
author nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
date Tue, 22 Mar 2011 17:18:12 +0900
parents 77e2b8dfacca
children 04ced10e8804
comparison
equal deleted inserted replaced
13:65488c3d617d 14:f6334be47118
1 /* Natural loop analysis code for GNU compiler. 1 /* Natural loop analysis code for GNU compiler.
2 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 2 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 4
5 This file is part of GCC. 5 This file is part of GCC.
6 6
7 GCC is free software; you can redistribute it and/or modify it under 7 GCC is free software; you can redistribute it and/or modify it under
30 #include "expr.h" 30 #include "expr.h"
31 #include "output.h" 31 #include "output.h"
32 #include "graphds.h" 32 #include "graphds.h"
33 #include "params.h" 33 #include "params.h"
34 34
35 struct target_cfgloop default_target_cfgloop;
36 #if SWITCHABLE_TARGET
37 struct target_cfgloop *this_target_cfgloop = &default_target_cfgloop;
38 #endif
39
35 /* Checks whether BB is executed exactly once in each LOOP iteration. */ 40 /* Checks whether BB is executed exactly once in each LOOP iteration. */
36 41
37 bool 42 bool
38 just_once_each_iteration_p (const struct loop *loop, const_basic_block bb) 43 just_once_each_iteration_p (const struct loop *loop, const_basic_block bb)
39 { 44 {
315 } 320 }
316 321
317 return cost; 322 return cost;
318 } 323 }
319 324
320 /* The properties of the target. */
321
322 unsigned target_avail_regs; /* Number of available registers. */
323 unsigned target_res_regs; /* Number of registers reserved for temporary
324 expressions. */
325 unsigned target_reg_cost[2]; /* The cost for register when there still
326 is some reserve, but we are approaching
327 the number of available registers. */
328 unsigned target_spill_cost[2]; /* The cost for register when we need
329 to spill. */
330
331 /* Initialize the constants for computing set costs. */ 325 /* Initialize the constants for computing set costs. */
332 326
333 void 327 void
334 init_set_costs (void) 328 init_set_costs (void)
335 { 329 {
340 rtx addr = gen_raw_REG (Pmode, FIRST_PSEUDO_REGISTER + 2); 334 rtx addr = gen_raw_REG (Pmode, FIRST_PSEUDO_REGISTER + 2);
341 rtx mem = validize_mem (gen_rtx_MEM (SImode, addr)); 335 rtx mem = validize_mem (gen_rtx_MEM (SImode, addr));
342 unsigned i; 336 unsigned i;
343 337
344 target_avail_regs = 0; 338 target_avail_regs = 0;
339 target_clobbered_regs = 0;
345 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) 340 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
346 if (TEST_HARD_REG_BIT (reg_class_contents[GENERAL_REGS], i) 341 if (TEST_HARD_REG_BIT (reg_class_contents[GENERAL_REGS], i)
347 && !fixed_regs[i]) 342 && !fixed_regs[i])
348 target_avail_regs++; 343 {
344 target_avail_regs++;
345 if (call_used_regs[i])
346 target_clobbered_regs++;
347 }
349 348
350 target_res_regs = 3; 349 target_res_regs = 3;
351 350
352 for (speed = 0; speed < 2; speed++) 351 for (speed = 0; speed < 2; speed++)
353 { 352 {
377 default_rtl_profile (); 376 default_rtl_profile ();
378 } 377 }
379 378
380 /* Estimates cost of increased register pressure caused by making N_NEW new 379 /* Estimates cost of increased register pressure caused by making N_NEW new
381 registers live around the loop. N_OLD is the number of registers live 380 registers live around the loop. N_OLD is the number of registers live
382 around the loop. */ 381 around the loop. If CALL_P is true, also take into account that
382 call-used registers may be clobbered in the loop body, reducing the
383 number of available registers before we spill. */
383 384
384 unsigned 385 unsigned
385 estimate_reg_pressure_cost (unsigned n_new, unsigned n_old, bool speed) 386 estimate_reg_pressure_cost (unsigned n_new, unsigned n_old, bool speed,
387 bool call_p)
386 { 388 {
387 unsigned cost; 389 unsigned cost;
388 unsigned regs_needed = n_new + n_old; 390 unsigned regs_needed = n_new + n_old;
391 unsigned available_regs = target_avail_regs;
392
393 /* If there is a call in the loop body, the call-clobbered registers
394 are not available for loop invariants. */
395 if (call_p)
396 available_regs = available_regs - target_clobbered_regs;
389 397
390 /* If we have enough registers, we should use them and not restrict 398 /* If we have enough registers, we should use them and not restrict
391 the transformations unnecessarily. */ 399 the transformations unnecessarily. */
392 if (regs_needed + target_res_regs <= target_avail_regs) 400 if (regs_needed + target_res_regs <= available_regs)
393 return 0; 401 return 0;
394 402
395 if (regs_needed <= target_avail_regs) 403 if (regs_needed <= available_regs)
396 /* If we are close to running out of registers, try to preserve 404 /* If we are close to running out of registers, try to preserve
397 them. */ 405 them. */
398 cost = target_reg_cost [speed] * n_new; 406 cost = target_reg_cost [speed] * n_new;
399 else 407 else
400 /* If we run out of registers, it is very expensive to add another 408 /* If we run out of registers, it is very expensive to add another