Optimize quad == 0 comparisons.

This commit is contained in:
Stephen Heumann 2021-02-25 21:40:32 -06:00
parent 5c92a8a0d3
commit 36d31ab37c

17
Gen.pas
View File

@ -2308,7 +2308,18 @@ else
end; {case optype of cgReal..cgExtended}
cgQuad,cgUQuad: begin
if SimpleQuadLoad(op^.left) and SimpleQuadLoad(op^.right)
if SimpleQuadLoad(op^.left) and (op^.right^.opcode = pc_ldc)
and (op^.right^.qval.hi = 0) and (op^.right^.qval.lo = 0) then begin
lab1 := GenLabel;
OpOnWordOfQuad(m_lda_imm, op^.left, 0);
if not volatile then
GenNative(m_bne, relative, lab1, nil, 0);
OpOnWordOfQuad(m_ora_imm, op^.left, 2);
OpOnWordOfQuad(m_ora_imm, op^.left, 4);
OpOnWordOfQuad(m_ora_imm, op^.left, 6);
GenLab(lab1);
end {if}
else if SimpleQuadLoad(op^.left) and SimpleQuadLoad(op^.right)
and not volatile then begin
lab1 := GenLabel;
OpOnWordOfQuad(m_lda_imm, op^.left, 0);
@ -5019,6 +5030,8 @@ case op^.opcode of {do the operation}
end; {GenUnaryQuad}
{$segment 'gen2'}
procedure GenTree {op: icptr};
{ generate code for op and its children }
@ -7116,8 +7129,6 @@ end; {GenTree}
{---------------------------------------------------------------}
{$segment 'gen2'}
procedure Gen {blk: blockPtr};
{ Generates native code for a list of blocks }