瀏覽代碼

* let the operation do the type conversion for x87 floating point operations

git-svn-id: trunk@43867 -
florian 5 年之前
父節點
當前提交
fca4d3315b
共有 1 個文件被更改,包括 18 次插入2 次删除
  1. 18 2
      compiler/x86/nx86add.pas

+ 18 - 2
compiler/x86/nx86add.pas

@@ -77,7 +77,7 @@ unit nx86add;
       symconst,symdef,
       symconst,symdef,
       cgobj,hlcgobj,cgx86,cga,cgutils,
       cgobj,hlcgobj,cgx86,cga,cgutils,
       tgobj,ncgutil,
       tgobj,ncgutil,
-      ncon,nset,ninl,
+      ncon,nset,ninl,ncnv,
       defutil,
       defutil,
       htypechk;
       htypechk;
 
 
@@ -1292,7 +1292,7 @@ unit nx86add;
         ops_rdiv: array[boolean] of TAsmOp = (A_FDIVRP,A_FDIVR);
         ops_rdiv: array[boolean] of TAsmOp = (A_FDIVRP,A_FDIVR);
       var
       var
         op : TAsmOp;
         op : TAsmOp;
-        refnode : tnode;
+        refnode, hp: tnode;
         hasref : boolean;
         hasref : boolean;
       begin
       begin
         if use_vectorfpu(resultdef) then
         if use_vectorfpu(resultdef) then
@@ -1304,6 +1304,22 @@ unit nx86add;
             exit;
             exit;
           end;
           end;
 
 
+        { can the operation do the conversion? }
+        if (left.nodetype=typeconvn) and (is_double(ttypeconvnode(left).left.resultdef) or is_single(ttypeconvnode(left).left.resultdef)) then
+          begin
+            hp:=left;
+            left:=ttypeconvnode(left).left;
+            ttypeconvnode(hp).left:=nil;
+            hp.Free;
+          end;
+        if (right.nodetype=typeconvn) and (is_double(ttypeconvnode(right).left.resultdef) or is_single(ttypeconvnode(right).left.resultdef)) then
+          begin
+            hp:=right;
+            right:=ttypeconvnode(right).left;
+            ttypeconvnode(hp).left:=nil;
+            hp.Free;
+          end;
+
         pass_left_right;
         pass_left_right;
         prepare_x87_locations(refnode);
         prepare_x87_locations(refnode);
         hasref:=assigned(refnode);
         hasref:=assigned(refnode);