Просмотр исходного кода

* process fma intrinsic parameters in an order which takes care of multiple x87 stack parameters, resolves #38295

git-svn-id: trunk@48017 -
florian 4 лет назад
Родитель
Сommit
9592c033e5
3 измененных файлов с 23 добавлено и 1 удалено
  1. 1 0
      .gitattributes
  2. 3 1
      compiler/x86/nx86inl.pas
  3. 19 0
      tests/webtbs/tw38295.pp

+ 1 - 0
.gitattributes

@@ -18630,6 +18630,7 @@ tests/webtbs/tw38267a.pp svneol=native#text/pascal
 tests/webtbs/tw38267b.pp svneol=native#text/pascal
 tests/webtbs/tw38267b.pp svneol=native#text/pascal
 tests/webtbs/tw3827.pp svneol=native#text/plain
 tests/webtbs/tw3827.pp svneol=native#text/plain
 tests/webtbs/tw3829.pp svneol=native#text/plain
 tests/webtbs/tw3829.pp svneol=native#text/plain
+tests/webtbs/tw38295.pp svneol=native#text/pascal
 tests/webtbs/tw3833.pp svneol=native#text/plain
 tests/webtbs/tw3833.pp svneol=native#text/plain
 tests/webtbs/tw3840.pp svneol=native#text/plain
 tests/webtbs/tw3840.pp svneol=native#text/plain
 tests/webtbs/tw3841.pp svneol=native#text/plain
 tests/webtbs/tw3841.pp svneol=native#text/plain

+ 3 - 1
compiler/x86/nx86inl.pas

@@ -1223,7 +1223,9 @@ implementation
              { only one memory operand is allowed }
              { only one memory operand is allowed }
              gotmem:=false;
              gotmem:=false;
              memop:=0;
              memop:=0;
-             for i:=1 to 3 do
+             { in case parameters come on the FPU stack, we have to pop them in reverse order as we
+               called secondpass }
+             for i:=3 downto 1 do
                begin
                begin
                  if not(paraarray[i].location.loc in [LOC_MMREGISTER,LOC_CMMREGISTER]) then
                  if not(paraarray[i].location.loc in [LOC_MMREGISTER,LOC_CMMREGISTER]) then
                    begin
                    begin

+ 19 - 0
tests/webtbs/tw38295.pp

@@ -0,0 +1,19 @@
+{ %cpu=i386 }
+{ %opt=-CfAVX -CpCOREAVX2 -OoFASTMATH }
+uses
+  cpu;
+var
+    a, b: uint32; // or (u)int64; int32 works
+    r: single; // or double, or even extended
+begin
+  if FMASupport then
+    begin
+      a := 1;
+      b := 3;
+      r := a + b / 10;
+      writeln(r:0:3);
+      if r>2.0 then
+         halt(1);
+      writeln('ok');
+    end;
+end.