]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Extend applicability of register preferencing scheme.
authorJulian Seward <jseward@acm.org>
Fri, 29 Oct 2004 01:29:26 +0000 (01:29 +0000)
committerJulian Seward <jseward@acm.org>
Fri, 29 Oct 2004 01:29:26 +0000 (01:29 +0000)
This all needs to be re-considered properly.

git-svn-id: svn://svn.valgrind.org/vex/trunk@456

VEX/priv/host-generic/reg_alloc.c

index bc86442bd3dc249b333a9fd39d5c528978c0b711..fa80976a7d13da8610d379d3157260d764a0dab0 100644 (file)
@@ -877,11 +877,24 @@ HInstrArray* doRegisterAllocation (
             so, bag it.  NOTE, we could improve this by selecting an
             rreg for which the next live-range event is as far ahead
             as possible. */
+         k_suboptimal = -1;
          for (k = 0; k < n_state; k++) {
-            if (state[k].disp == Free
-                && hregClass(state[k].rreg) == hregClass(vreg))
+            if (state[k].disp != Free
+                || hregClass(state[k].rreg) != hregClass(vreg))
+               continue;
+            if (state[k].has_hlrs) {
+               /* Well, at least we can use k_suboptimal if we really
+                  have to.  Keep on looking for a better candidate. */
+               k_suboptimal = k;
+            } else {
+               /* Found a preferable reg.  Use it. */
+               k_suboptimal = -1;
                break;
+            }
          }
+         if (k_suboptimal >= 0)
+            k = k_suboptimal;
+
          if (k < n_state) {
             state[k].disp = Bound;
             state[k].vreg = vreg;