Improve search for available spill slots in RA
Previously we always searched for two adjacent spill slots, even if
we only needed one. This small change fixes that.
Test: m test-art-host
Change-Id: I021d355e6602ffee687c8537a959232b1504dcf1
diff --git a/compiler/optimizing/register_allocator.cc b/compiler/optimizing/register_allocator.cc
index 9d99668..1b33408 100644
--- a/compiler/optimizing/register_allocator.cc
+++ b/compiler/optimizing/register_allocator.cc
@@ -1346,9 +1346,15 @@
// Find an available spill slot.
size_t slot = 0;
for (size_t e = spill_slots->size(); slot < e; ++slot) {
- if ((*spill_slots)[slot] <= parent->GetStart()
- && (slot == (e - 1) || (*spill_slots)[slot + 1] <= parent->GetStart())) {
- break;
+ if ((*spill_slots)[slot] <= parent->GetStart()) {
+ if (!parent->NeedsTwoSpillSlots()) {
+ // One spill slot is sufficient.
+ break;
+ }
+ if (slot == e - 1 || (*spill_slots)[slot + 1] <= parent->GetStart()) {
+ // Two spill slots are available.
+ break;
+ }
}
}