shithub: mc

Download patch

ref: 7fdee7419531c20ed3fe8c71634ff077f094a518
parent: 97635cb8850d14b42c4e6882d0d7b6aa05485271
author: Ori Bernstein <[email protected]>
date: Wed Oct 2 15:41:46 EDT 2013

Emit the right pseudo instructions for negating a float.

--- a/6/isel.c
+++ b/6/isel.c
@@ -459,6 +459,7 @@
     Loc *a, *b, *c, *d, *r;
     Loc *eax, *edx, *cl; /* x86 wants some hard-coded regs */
     Node **args;
+    int sz;
 
     args = n->expr.args;
     eax = locphysreg(Reax);
@@ -506,7 +507,22 @@
         case Oneg:
             r = selexpr(s, args[0]);
             r = inr(s, r);
-            g(s, Ineg, r, NULL);
+            if (floatnode(args[0])) {
+                sz = size(args[0]);
+                if (sz == 4) {
+                    a = locreg(ModeD);
+                    b = loclit(1 << (8*sz-1), ModeD);
+                    g(s, Imov, r, a);
+                } else if (size(args[0]) == 8) {
+                    a = locreg(ModeQ);
+                    b = loclit(1 << (8*sz-1), ModeQ);
+                    g(s, Imov, r, a, NULL);
+                }
+                g(s, Ixor, b, a, NULL);
+                g(s, Imov, a, r, NULL);
+            } else {
+                g(s, Ineg, r, NULL);
+            }
             break;
 
         case Obsl: