From 36d31ab37cd6c8ee88be01e187a77ec160002c42 Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Thu, 25 Feb 2021 21:40:32 -0600 Subject: [PATCH] Optimize quad == 0 comparisons. --- Gen.pas | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Gen.pas b/Gen.pas index caaf6ad..ab572ef 100644 --- a/Gen.pas +++ b/Gen.pas @@ -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 }