Browse Source

* optimize vmovaps/vmovapd after avx instructions

git-svn-id: trunk@27712 -
florian 11 years ago
parent
commit
2fa066b003
1 changed files with 26 additions and 0 deletions
  1. 26 0
      compiler/x86_64/aoptcpu.pas

+ 26 - 0
compiler/x86_64/aoptcpu.pas

@@ -664,6 +664,32 @@ begin
                 end;
             end;
           end;
+        A_VDIVSD,
+        A_VDIVSS,
+        A_VSUBSD,
+        A_VSUBSS,
+        A_VMULSD,
+        A_VMULSS,
+        A_VADDSD,
+        A_VADDSS:
+          begin
+            if GetNextInstruction(p,hp1) and
+              { we mix single and double opperations here because we assume that the compiler
+                generates vmovapd only after double operations and vmovaps only after single operations }
+              MatchInstruction(hp1,A_VMOVAPD,A_VMOVAPS,[S_NO]) and
+              MatchOperand(taicpu(p).oper[2]^,taicpu(hp1).oper[0]^) and
+              (taicpu(hp1).oper[1]^.typ=top_reg) then
+              begin
+                CopyUsedRegs(TmpUsedRegs);
+                UpdateUsedRegs(TmpUsedRegs, tai(p.next));
+                If not(RegUsedAfterInstruction(taicpu(hp1).oper[0]^.reg,hp1,TmpUsedRegs)) then
+                  begin
+                    taicpu(p).loadoper(2,taicpu(hp1).oper[1]^);
+                    asml.Remove(hp1);
+                    hp1.Free;
+                  end;
+              end;
+          end;
         end;
       end;
     end;