shithub: mc

Download patch

ref: 991fa68f601d19c629ff2aa1fd819c8369251bee
parent: b6c2434f14ea813add4b925e0c5a14044d73b593
author: Ori Bernstein <[email protected]>
date: Thu Sep 27 17:48:39 EDT 2012

Don't clobber the register value.

--- a/6/isel.c
+++ b/6/isel.c
@@ -679,14 +679,24 @@
             }
             break;
         case Imov:
-            if (insn->args[0]->type == Locreg && insn->args[1]->type == Locreg &&
-                insn->args[0]->reg.colour != Rnone && insn->args[1]->reg.colour != Rnone) {
-                if (insn->args[0]->mode != insn->args[1]->mode)
-                    insn->args[0] = coreg(insn->args[1]->reg.colour, insn->args[1]->mode);
-                /* moving a reg to itself is dumb. */
-                if (insn->args[0]->reg.colour == insn->args[1]->reg.colour)
-                    return;
+            if (insn->args[0]->type != Locreg || insn->args[1]->type != Locreg)
+                break;
+            if (insn->args[0]->reg.colour == Rnone || insn->args[1]->reg.colour == Rnone)
+                break;
+            /* if one reg is a subreg of another, we can just use the right
+             * mode to move between them. */
+            if (insn->args[0]->mode != insn->args[1]->mode)
+                insn->args[0] = coreg(insn->args[0]->reg.colour, insn->args[1]->mode);
+            /* moving a reg to itself is dumb. */
+            if (insn->args[0]->reg.colour == insn->args[1]->reg.colour) {
+                printf("SKIPPING mov ");
+                locprint(stdout, insn->args[0], 'x');
+                printf(" ");
+                locprint(stdout, insn->args[1], 'x');
+                printf("\n");
+                return;
             }
+            break;
         default:
             break;
     }