0548-ira-Increase-the-cost-of-inner-loop-spill.patch 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. From 0582802db83d7cce8d3528aa8c2fd952c6537f59 Mon Sep 17 00:00:00 2001
  2. From: "max.ma" <max.ma@starfivetech.com>
  3. Date: Mon, 26 Jun 2023 20:27:50 -0700
  4. Subject: [PATCH 1/1] ira: Increase the cost of inner loop spill
  5. ---
  6. gcc/ira-costs.cc | 10 ++++++++++
  7. 1 file changed, 10 insertions(+)
  8. diff --git a/gcc/ira-costs.cc b/gcc/ira-costs.cc
  9. index 964c94a06ef..d2040f04be7 100644
  10. --- a/gcc/ira-costs.cc
  11. +++ b/gcc/ira-costs.cc
  12. @@ -34,6 +34,7 @@ along with GCC; see the file COPYING3. If not see
  13. #include "ira-int.h"
  14. #include "addresses.h"
  15. #include "reload.h"
  16. +#include "cfgloop.h"
  17. /* The flags is set up every time when we calculate pseudo register
  18. classes through function ira_set_pseudo_classes. */
  19. @@ -1624,10 +1625,19 @@ static void
  20. process_bb_for_costs (basic_block bb)
  21. {
  22. rtx_insn *insn;
  23. + int depth;
  24. frequency = REG_FREQ_FROM_BB (bb);
  25. if (frequency == 0)
  26. frequency = 1;
  27. + if (bb->loop_father)
  28. + {
  29. + depth = loop_depth(bb->loop_father);
  30. + depth = depth > 5 ? 5 : depth;
  31. + while (depth--)
  32. + frequency *= 5;
  33. + }
  34. +
  35. FOR_BB_INSNS (bb, insn)
  36. insn = scan_one_insn (insn);
  37. }
  38. --
  39. 2.25.1