summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlaksen <laksen@3ad0048d-3df7-0310-abae-a5850022a9f2>2018-07-22 16:58:10 +0000
committerlaksen <laksen@3ad0048d-3df7-0310-abae-a5850022a9f2>2018-07-22 16:58:10 +0000
commitf8053ed623ee77f207ca97e05c66b6d1e0919c02 (patch)
tree5bd97c98b45e946613929b3ea3a67cce4c83c396
parent1b7c2166643e3faae1a65cd336dbcb7e8bceb807 (diff)
downloadfpc-f8053ed623ee77f207ca97e05c66b6d1e0919c02.tar.gz
Fixed bug in peephole optimizer.
git-svn-id: https://svn.freepascal.org/svn/fpc/branches/laksen@39486 3ad0048d-3df7-0310-abae-a5850022a9f2
-rw-r--r--riscv_new/compiler/riscv/aasmcpu.pas8
-rw-r--r--riscv_new/compiler/riscv64/aoptcpu.pas1
2 files changed, 9 insertions, 0 deletions
diff --git a/riscv_new/compiler/riscv/aasmcpu.pas b/riscv_new/compiler/riscv/aasmcpu.pas
index 30acbaa154..c6b1baa5c8 100644
--- a/riscv_new/compiler/riscv/aasmcpu.pas
+++ b/riscv_new/compiler/riscv/aasmcpu.pas
@@ -527,6 +527,14 @@ uses cutils, cclasses;
function taicpu.spilling_get_operation_type_ref(opnr: longint; reg: tregister): topertype;
begin
result := operand_read;
+ case opcode of
+{$ifdef RISCV64}
+ A_SD,
+{$endif RISCV64}
+ A_SB,A_SH,A_SW:
+ if opnr=1 then
+ result:=operand_write;
+ end;
end;
diff --git a/riscv_new/compiler/riscv64/aoptcpu.pas b/riscv_new/compiler/riscv64/aoptcpu.pas
index 34ae3695ad..3eb1bd9bbe 100644
--- a/riscv_new/compiler/riscv64/aoptcpu.pas
+++ b/riscv_new/compiler/riscv64/aoptcpu.pas
@@ -112,6 +112,7 @@ implementation
(hp1.typ=ait_instruction) and
(taicpu(hp1).opcode=A_ADDI) and
(taicpu(hp1).ops=3) and
+ (taicpu(p).oper[0]^.reg=taicpu(hp1).oper[1]^.reg) and
(taicpu(p).oper[2]^.typ=top_const) and
is_imm12(taicpu(p).oper[2]^.val+taicpu(hp1).oper[2]^.val) and
(not RegModifiedBetween(taicpu(p).oper[1]^.reg, p,hp1)) and