瀏覽代碼

* handle LOC_*FPUREGISTER correctly when using sse2 sqr, resolve #26408

git-svn-id: trunk@24909 -
florian 12 年之前
父節點
當前提交
fc72490166
共有 3 個文件被更改,包括 25 次插入1 次删除
  1. 1 0
      .gitattributes
  2. 3 1
      compiler/x86/nx86inl.pas
  3. 21 0
      tests/webtbs/tw26408.pp

+ 1 - 0
.gitattributes

@@ -13474,6 +13474,7 @@ tests/webtbs/tw2620.pp svneol=native#text/plain
 tests/webtbs/tw2626.pp svneol=native#text/plain
 tests/webtbs/tw2627.pp svneol=native#text/plain
 tests/webtbs/tw2631.pp svneol=native#text/plain
+tests/webtbs/tw26408.pp svneol=native#text/pascal
 tests/webtbs/tw2643.pp svneol=native#text/plain
 tests/webtbs/tw2645.pp svneol=native#text/plain
 tests/webtbs/tw2647.pp svneol=native#text/plain

+ 3 - 1
compiler/x86/nx86inl.pas

@@ -400,6 +400,8 @@ implementation
                end
              else
                begin
+                 if left.location.loc in [LOC_CFPUREGISTER,LOC_FPUREGISTER] then
+                   hlcg.location_force_mmregscalar(current_asmdata.CurrAsmList,left.location,left.resultdef,true);
                  cg.a_loadmm_loc_reg(current_asmdata.CurrAsmList,location.size,left.location,location.register,mms_movescalar);
                  cg.a_opmm_reg_reg(current_asmdata.CurrAsmList,OP_MUL,left.location.size,location.register,location.register,mms_movescalar);
                end;
@@ -417,7 +419,7 @@ implementation
          if use_vectorfpu(resultdef) then
            begin
              secondpass(left);
-             hlcg.location_force_mmregscalar(current_asmdata.CurrAsmList,left.location,left.resultdef,false);
+             hlcg.location_force_mmregscalar(current_asmdata.CurrAsmList,left.location,left.resultdef,true);
              location_reset(location,LOC_MMREGISTER,left.location.size);
              location.register:=cg.getmmregister(current_asmdata.CurrAsmList,location.size);
              if UseAVX then

+ 21 - 0
tests/webtbs/tw26408.pp

@@ -0,0 +1,21 @@
+{$mode objfpc}
+program bugavx64;
+
+uses math;
+
+function EllipseRadialLength(Width, Height:Integer; EccentricAngle : Extended) : Extended;
+var
+  a, b, R : Extended;
+begin
+  a := Width div 2;
+  b := Height div 2;
+  R := Sqr(a)*Sqr(b);
+  if R <> 0 then begin // tweak
+    R := Sqrt(R / ((Sqr(b)*Sqr(Cos(DegToRad(EccentricAngle/16))))) +
+      (Sqr(a)*Sqr(Sin(DegToRad(EccentricAngle/16)))));
+  end;
+  Result := R;
+end;
+
+begin
+end.