From c03f19fa500c991ec8587e82390fef3144749af8 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Sun, 14 Oct 2007 20:22:23 +0000 Subject: [PATCH] * 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 - --- .gitattributes | 1 + compiler/i386/daopt386.pas | 11 +++++++---- tests/test/opt/tspace.pp | 20 ++++++++++++++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 tests/test/opt/tspace.pp diff --git a/.gitattributes b/.gitattributes index 507005959d..3e641ad76b 100644 --- a/.gitattributes +++ b/.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/treg4.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/t4cc2.pp svneol=native#text/plain tests/test/tabstrcl.pp svneol=native#text/plain diff --git a/compiler/i386/daopt386.pas b/compiler/i386/daopt386.pas index dad98ba402..f6bfd944e5 100644 --- a/compiler/i386/daopt386.pas +++ b/compiler/i386/daopt386.pas @@ -1124,10 +1124,13 @@ begin (p.oper[1]^.typ = top_reg) and (getsupreg(p.oper[1]^.reg) = supreg) and (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; procedure UpdateUsedRegs(var UsedRegs: TRegSet; p: tai); diff --git a/tests/test/opt/tspace.pp b/tests/test/opt/tspace.pp new file mode 100644 index 0000000000..713dcf7214 --- /dev/null +++ b/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.