summaryrefslogtreecommitdiff
path: root/compiler/avr/aoptcpu.pas
diff options
context:
space:
mode:
authorflorian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2>2018-03-10 21:53:45 +0000
committerflorian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2>2018-03-10 21:53:45 +0000
commit2dc54b83c90db5dae52550ebb6692e005c4a9baf (patch)
tree01b0009860a92627c69a1daac47d888f1ba1b835 /compiler/avr/aoptcpu.pas
parentbb19d554129044013dc811e2ab843f686556da01 (diff)
downloadfpc-2dc54b83c90db5dae52550ebb6692e005c4a9baf.tar.gz
* improved OpCp2Op
git-svn-id: https://svn.freepascal.org/svn/fpc/trunk@38486 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'compiler/avr/aoptcpu.pas')
-rw-r--r--compiler/avr/aoptcpu.pas10
1 files changed, 7 insertions, 3 deletions
diff --git a/compiler/avr/aoptcpu.pas b/compiler/avr/aoptcpu.pas
index a0539f2d97..7440d5aa20 100644
--- a/compiler/avr/aoptcpu.pas
+++ b/compiler/avr/aoptcpu.pas
@@ -251,7 +251,7 @@ Implementation
(taicpu(hp1).oper[0]^.reg = NR_R1) and
(taicpu(p).opcode in [A_ADC,A_ADD,A_AND,A_ANDI,A_ASR,A_COM,A_EOR,
A_LSL,A_LSR,
- A_OR,A_ORI,A_ROL,A_ROR])))) or
+ A_OR,A_ORI,A_ROL,A_ROR,A_SUB,A_SBI])))) or
(MatchInstruction(hp1, A_CPI) and
(taicpu(p).opcode = A_ANDI) and
(taicpu(p).oper[1]^.typ=top_const) and
@@ -266,7 +266,9 @@ Implementation
EQ = Z=1; NE = Z=0;
MI = N=1; PL = N=0; }
MatchInstruction(hp2, A_BRxx) and
- (taicpu(hp2).condition in [C_EQ,C_NE,C_MI,C_PL]) { and
+ ((taicpu(hp2).condition in [C_EQ,C_NE,C_MI,C_PL]) or
+ { sub/sbc set all flags }
+ (taicpu(p).opcode in [A_SUB,A_SBI])){ and
no flag allocation tracking implemented yet on avr
assigned(FindRegDealloc(NR_DEFAULTFLAGS,tai(hp2.Next)))} then
begin
@@ -282,7 +284,9 @@ Implementation
}
// If we compare to the same value we are masking then invert the comparison
- if (taicpu(hp1).opcode=A_CPI) then
+ if (taicpu(hp1).opcode=A_CPI) or
+ { sub/sbc with reverted? }
+ ((taicpu(hp1).oper[0]^.reg = NR_R1) and (taicpu(p).opcode in [A_SUB,A_SBI])) then
taicpu(hp2).condition:=inverse_cond(taicpu(hp2).condition);
asml.InsertBefore(tai_regalloc.alloc(NR_DEFAULTFLAGS,p), p);