summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornickysn <nickysn@3ad0048d-3df7-0310-abae-a5850022a9f2>2020-04-26 17:24:53 +0000
committernickysn <nickysn@3ad0048d-3df7-0310-abae-a5850022a9f2>2020-04-26 17:24:53 +0000
commitb671482efe2d43621cf7b29f611257e22098eee9 (patch)
tree83e637e435276a96acb207e943e669a8261851b8
parent91e068b8033101842ba0f55de809512363c92b2d (diff)
downloadfpc-b671482efe2d43621cf7b29f611257e22098eee9.tar.gz
+ generate better code in op_const_reg for OP_ADD and OP_SUB by using in certain cases A_DEC for OP_SUB
and A_INC for OP_ADD git-svn-id: https://svn.freepascal.org/svn/fpc/branches/z80@45120 3ad0048d-3df7-0310-abae-a5850022a9f2
-rw-r--r--compiler/z80/cgcpu.pas8
1 files changed, 6 insertions, 2 deletions
diff --git a/compiler/z80/cgcpu.pas b/compiler/z80/cgcpu.pas
index 856e7ee706..12d1f34f36 100644
--- a/compiler/z80/cgcpu.pas
+++ b/compiler/z80/cgcpu.pas
@@ -1105,6 +1105,8 @@ unit cgcpu;
begin
if (tmpop=A_NONE) and (curvalue=1) and (i=tcgsize2size[size]) then
tmpop:=A_INC
+ else if (tmpop=A_NONE) and (curvalue=255) and (i=tcgsize2size[size]) then
+ tmpop:=A_DEC
else if (tmpop=A_NONE) and (curvalue<>0) then
tmpop:=A_ADD
else if tmpop=A_ADD then
@@ -1112,7 +1114,7 @@ unit cgcpu;
case tmpop of
A_NONE:
{nothing};
- A_INC:
+ A_INC,A_DEC:
list.concat(taicpu.op_reg(tmpop,reg));
A_ADD,A_ADC:
begin
@@ -1142,6 +1144,8 @@ unit cgcpu;
begin
if (tmpop=A_NONE) and (curvalue=1) and (i=tcgsize2size[size]) then
tmpop:=A_DEC
+ else if (tmpop=A_NONE) and (curvalue=255) and (i=tcgsize2size[size]) then
+ tmpop:=A_INC
else if (tmpop=A_NONE) and (curvalue<>0) then
tmpop:=A_SUB
else if tmpop=A_SUB then
@@ -1149,7 +1153,7 @@ unit cgcpu;
case tmpop of
A_NONE:
{nothing};
- A_DEC:
+ A_DEC,A_INC:
list.concat(taicpu.op_reg(tmpop,reg));
A_SUB,A_SBC:
begin