Browse Source

* in case of "movzbl %dl,%edx" etc, %edx depends on its previous value.
regloadedwithnewvalue() gave the wrong answer for this in case
candependonprevvalue was false (caused a wrong optimization in the
space() function of the rtl)

git-svn-id: trunk@8808 -

Jonas Maebe 18 years ago
parent
commit
c03f19fa50
3 changed files with 28 additions and 4 deletions
  1. 1 0
      .gitattributes
  2. 7 4
      compiler/i386/daopt386.pas
  3. 20 0
      tests/test/opt/tspace.pp

+ 1 - 0
.gitattributes

@@ -6839,6 +6839,7 @@ tests/test/opt/treg2.pp svneol=native#text/plain
 tests/test/opt/treg3.pp svneol=native#text/plain
 tests/test/opt/treg3.pp svneol=native#text/plain
 tests/test/opt/treg4.pp svneol=native#text/plain
 tests/test/opt/treg4.pp svneol=native#text/plain
 tests/test/opt/tretopt.pp svneol=native#text/plain
 tests/test/opt/tretopt.pp svneol=native#text/plain
+tests/test/opt/tspace.pp svneol=native#text/plain
 tests/test/t4cc1.pp svneol=native#text/plain
 tests/test/t4cc1.pp svneol=native#text/plain
 tests/test/t4cc2.pp svneol=native#text/plain
 tests/test/t4cc2.pp svneol=native#text/plain
 tests/test/tabstrcl.pp svneol=native#text/plain
 tests/test/tabstrcl.pp svneol=native#text/plain

+ 7 - 4
compiler/i386/daopt386.pas

@@ -1124,10 +1124,13 @@ begin
      (p.oper[1]^.typ = top_reg) and
      (p.oper[1]^.typ = top_reg) and
      (getsupreg(p.oper[1]^.reg) = supreg) and
      (getsupreg(p.oper[1]^.reg) = supreg) and
      (canDependOnPrevValue or
      (canDependOnPrevValue or
-      (p.oper[0]^.typ <> top_ref) or
-      not regInRef(supreg,p.oper[0]^.ref^)) or
-     ((p.opcode = A_POP) and
-      (getsupreg(p.oper[0]^.reg) = supreg)));
+      (p.oper[0]^.typ = top_const) or
+      ((p.oper[0]^.typ = top_reg) and
+       (getsupreg(p.oper[0]^.reg) <> supreg)) or
+      ((p.oper[0]^.typ = top_ref) and
+       not regInRef(supreg,p.oper[0]^.ref^)))) or
+    ((p.opcode = A_POP) and
+     (getsupreg(p.oper[0]^.reg) = supreg));
 end;
 end;
 
 
 procedure UpdateUsedRegs(var UsedRegs: TRegSet; p: tai);
 procedure UpdateUsedRegs(var UsedRegs: TRegSet; p: tai);

+ 20 - 0
tests/test/opt/tspace.pp

@@ -0,0 +1,20 @@
+{ %opt=-O2 }
+
+function space (b : byte): shortstring;
+begin
+  space[0] := chr(b);
+  FillChar (Space[1],b,' ');
+end;
+
+var
+  s: string;
+  i: longint;
+begin
+  fillchar(s,sizeof(s),255);
+  s:=space(255);
+  if length(s)<>255 then
+    halt(1);
+  for i:=1 to 255 do
+    if s[i]<>' ' then
+      halt(2);
+end.