浏览代码

* use source register as second register in VCVTSD2SS and VCVTSS2SD, this should break
dependency chains better and resolves partially #39360

florian 3 年之前
父节点
当前提交
4752230c8f
共有 2 个文件被更改,包括 15 次插入5 次删除
  1. 14 4
      compiler/x86/aoptx86.pas
  2. 1 1
      compiler/x86/cgx86.pas

+ 14 - 4
compiler/x86/aoptx86.pas

@@ -5874,14 +5874,24 @@ unit aoptx86;
            MatchOpType(taicpu(hp1),top_reg,top_reg,top_reg) and
            MatchOpType(taicpu(hp1),top_reg,top_reg,top_reg) and
            (getsupreg(taicpu(p).oper[0]^.reg)=getsupreg(taicpu(p).oper[1]^.reg)) and
            (getsupreg(taicpu(p).oper[0]^.reg)=getsupreg(taicpu(p).oper[1]^.reg)) and
            (getsupreg(taicpu(hp1).oper[0]^.reg)=getsupreg(taicpu(hp1).oper[1]^.reg)) and
            (getsupreg(taicpu(hp1).oper[0]^.reg)=getsupreg(taicpu(hp1).oper[1]^.reg)) and
-           (getsupreg(taicpu(p).oper[0]^.reg)=getsupreg(taicpu(hp1).oper[2]^.reg)) and
            (getsupreg(taicpu(p).oper[2]^.reg)=getsupreg(taicpu(hp1).oper[0]^.reg))
            (getsupreg(taicpu(p).oper[2]^.reg)=getsupreg(taicpu(hp1).oper[0]^.reg))
           )
           )
          ) then
          ) then
          begin
          begin
-           DebugMsg(SPeepholeOptimization + '(V)Cvtss2CvtSd(V)Cvtsd2ss2Nop done',p);
-           RemoveCurrentP(p);
-           RemoveInstruction(hp1);
+           if getsupreg(taicpu(p).oper[0]^.reg)=getsupreg(taicpu(hp1).oper[2]^.reg) then
+             begin
+               DebugMsg(SPeepholeOptimization + '(V)Cvtss2CvtSd(V)Cvtsd2ss2Nop done',p);
+               RemoveCurrentP(p);
+               RemoveInstruction(hp1);
+             end
+           else
+             begin
+               DebugMsg(SPeepholeOptimization + '(V)Cvtss2CvtSd(V)Cvtsd2ss2Vmovss done',p);
+               taicpu(p).loadreg(1,taicpu(hp1).oper[2]^.reg);
+               taicpu(p).ops:=2;
+               taicpu(p).opcode:=A_VMOVSS;
+               RemoveInstruction(hp1);
+             end;
            Result:=true;
            Result:=true;
            Exit;
            Exit;
          end;
          end;

+ 1 - 1
compiler/x86/cgx86.pas

@@ -1501,7 +1501,7 @@ unit cgx86;
 
 
             { A_VCVTSD2SS and A_VCVTSS2SD require always three operands }
             { A_VCVTSD2SS and A_VCVTSS2SD require always three operands }
             if (op=A_VCVTSD2SS) or (op=A_VCVTSS2SD) then
             if (op=A_VCVTSD2SS) or (op=A_VCVTSS2SD) then
-              instr:=taicpu.op_reg_reg_reg(op,S_NO,reg1,reg2,reg2)
+              instr:=taicpu.op_reg_reg_reg(op,S_NO,reg1,reg1,reg2)
             else
             else
               instr:=taicpu.op_reg_reg(op,S_NO,reg1,reg2);
               instr:=taicpu.op_reg_reg(op,S_NO,reg1,reg2);