+ also check the register type when checking for specific integer registers in

i386's TCpuAsmOptimizer.RegReadByInstruction. Previously, the lack of this
  check could generate false reads on some other register types (e.g. mmx/xmm/
  flags, etc.), and this could worsen optimizations.

git-svn-id: trunk@35957 -
This commit is contained in:
nickysn 2017-04-26 15:25:38 +00:00
parent 618b6292ee
commit 916c09af55

View File

@ -170,7 +170,7 @@ unit aoptcpu;
A_IDIV,A_DIV,A_MUL: A_IDIV,A_DIV,A_MUL:
begin begin
regReadByInstruction := regReadByInstruction :=
RegInOp(reg,p.oper[0]^) or (getsupreg(reg) in [RS_EAX,RS_EDX]); RegInOp(reg,p.oper[0]^) or ((getregtype(reg)=R_INTREGISTER) and (getsupreg(reg) in [RS_EAX,RS_EDX]));
end; end;
else else
begin begin
@ -183,56 +183,59 @@ unit aoptcpu;
end; end;
with insprop[p.opcode] do with insprop[p.opcode] do
begin begin
case getsupreg(reg) of if getregtype(reg)=R_INTREGISTER then
RS_EAX: begin
if [Ch_REAX,Ch_RWEAX,Ch_MEAX]*Ch<>[] then case getsupreg(reg) of
begin RS_EAX:
RegReadByInstruction := true; if [Ch_REAX,Ch_RWEAX,Ch_MEAX]*Ch<>[] then
exit begin
end; RegReadByInstruction := true;
RS_ECX: exit
if [Ch_RECX,Ch_RWECX,Ch_MECX]*Ch<>[] then end;
begin RS_ECX:
RegReadByInstruction := true; if [Ch_RECX,Ch_RWECX,Ch_MECX]*Ch<>[] then
exit begin
end; RegReadByInstruction := true;
RS_EDX: exit
if [Ch_REDX,Ch_RWEDX,Ch_MEDX]*Ch<>[] then end;
begin RS_EDX:
RegReadByInstruction := true; if [Ch_REDX,Ch_RWEDX,Ch_MEDX]*Ch<>[] then
exit begin
end; RegReadByInstruction := true;
RS_EBX: exit
if [Ch_REBX,Ch_RWEBX,Ch_MEBX]*Ch<>[] then end;
begin RS_EBX:
RegReadByInstruction := true; if [Ch_REBX,Ch_RWEBX,Ch_MEBX]*Ch<>[] then
exit begin
end; RegReadByInstruction := true;
RS_ESP: exit
if [Ch_RESP,Ch_RWESP,Ch_MESP]*Ch<>[] then end;
begin RS_ESP:
RegReadByInstruction := true; if [Ch_RESP,Ch_RWESP,Ch_MESP]*Ch<>[] then
exit begin
end; RegReadByInstruction := true;
RS_EBP: exit
if [Ch_REBP,Ch_RWEBP,Ch_MEBP]*Ch<>[] then end;
begin RS_EBP:
RegReadByInstruction := true; if [Ch_REBP,Ch_RWEBP,Ch_MEBP]*Ch<>[] then
exit begin
end; RegReadByInstruction := true;
RS_ESI: exit
if [Ch_RESI,Ch_RWESI,Ch_MESI]*Ch<>[] then end;
begin RS_ESI:
RegReadByInstruction := true; if [Ch_RESI,Ch_RWESI,Ch_MESI]*Ch<>[] then
exit begin
end; RegReadByInstruction := true;
RS_EDI: exit
if [Ch_REDI,Ch_RWEDI,Ch_MEDI]*Ch<>[] then end;
begin RS_EDI:
RegReadByInstruction := true; if [Ch_REDI,Ch_RWEDI,Ch_MEDI]*Ch<>[] then
exit begin
end; RegReadByInstruction := true;
end; exit
end;
end;
end;
if SuperRegistersEqual(reg,NR_DEFAULTFLAGS) then if SuperRegistersEqual(reg,NR_DEFAULTFLAGS) then
begin begin
case getsubreg(reg) of case getsubreg(reg) of