diff gen/asm-x86-32.h @ 1310:85b80c4fe48a

Fix certain cases of floating point instruction mistranslation.
author Christian Kamm <kamm incasoftware de>
date Thu, 07 May 2009 21:01:44 +0200
parents b995c146366e
children acc5d68a21d3
line wrap: on
line diff
--- a/gen/asm-x86-32.h	Wed May 06 19:56:33 2009 +0200
+++ b/gen/asm-x86-32.h	Thu May 07 21:01:44 2009 +0200
@@ -1880,15 +1880,11 @@
                 }
                 break;
                 
-                case Op_FMath0:
-                // the no-operand versions of floating point ops always pop
-                insnTemplate << mnemonic << "p";
-                break;
-                
                 default:
                 // special case fdiv, fsub: see dmd 840, ldc 256
-                if (strncmp(mnemonic, "fsub", 4) == 0 ||
-                    strncmp(mnemonic, "fdiv", 4) == 0)
+                if ((strncmp(mnemonic, "fsub", 4) == 0 ||
+                     strncmp(mnemonic, "fdiv", 4) == 0) && 
+                    operands[0].reg != Reg_ST)
                 {
                     // replace:
                     //   f{sub,div}r{p,} <-> f{sub,div}{p,}
@@ -1907,6 +1903,9 @@
                 {
                     insnTemplate << mnemonic;
                 }
+                // the no-operand versions of floating point ops always pop
+                if (op == Op_FMath0)
+                    insnTemplate << "p";
                 if ( type_char )
                     insnTemplate << type_char;
                 break;