From 10ae87f11c8db6b3ed99ecc3e56a3836eddc1b84 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Mon, 14 Oct 2013 12:49:34 +0000 Subject: [PATCH] * fixed LdrLdr2LdrMov optimisation in case the first and second ldr have a different size (disable it in that case) + test git-svn-id: trunk@25778 - --- .gitattributes | 1 + compiler/arm/aoptcpu.pas | 9 +++++---- tests/test/opt/tarmls1.pp | 23 +++++++++++++++++++++++ 3 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 tests/test/opt/tarmls1.pp diff --git a/.gitattributes b/.gitattributes index 9563927658..adb1477850 100644 --- a/.gitattributes +++ b/.gitattributes @@ -10754,6 +10754,7 @@ tests/test/library/ttdlltest.pp svneol=native#text/plain tests/test/library/ulib2a.pp svneol=native#text/plain tests/test/library/ulib2b.pp svneol=native#text/plain tests/test/opt/README.txt svneol=native#text/plain +tests/test/opt/tarmls1.pp svneol=native#text/plain tests/test/opt/tarmsa1.pp svneol=native#text/plain tests/test/opt/tarmshift.pp svneol=native#text/plain tests/test/opt/tcaseopt1.pp svneol=native#text/plain diff --git a/compiler/arm/aoptcpu.pas b/compiler/arm/aoptcpu.pas index ba416d2fec..370a07fbba 100644 --- a/compiler/arm/aoptcpu.pas +++ b/compiler/arm/aoptcpu.pas @@ -663,10 +663,11 @@ Implementation ldr reg1,ref mov reg2,reg1 } - if RefsEqual(taicpu(p).oper[1]^.ref^,taicpu(hp1).oper[1]^.ref^) and - (taicpu(p).oper[0]^.reg<>taicpu(hp1).oper[1]^.ref^.index) and - (taicpu(p).oper[0]^.reg<>taicpu(hp1).oper[1]^.ref^.base) and - (taicpu(hp1).oper[1]^.ref^.addressmode=AM_OFFSET) then + if (taicpu(p).oppostfix=taicpu(hp1).oppostfix) and + RefsEqual(taicpu(p).oper[1]^.ref^,taicpu(hp1).oper[1]^.ref^) and + (taicpu(p).oper[0]^.reg<>taicpu(hp1).oper[1]^.ref^.index) and + (taicpu(p).oper[0]^.reg<>taicpu(hp1).oper[1]^.ref^.base) and + (taicpu(hp1).oper[1]^.ref^.addressmode=AM_OFFSET) then begin if taicpu(hp1).oper[0]^.reg=taicpu(p).oper[0]^.reg then begin diff --git a/tests/test/opt/tarmls1.pp b/tests/test/opt/tarmls1.pp new file mode 100644 index 0000000000..ab3aa52134 --- /dev/null +++ b/tests/test/opt/tarmls1.pp @@ -0,0 +1,23 @@ +{ %opt=-O2 } + +type + trec = record + w: longint; + end; + +function test(var r: trec): byte; + +begin + test:=byte(r.w); + r.w:=r.w shr 8; +end; + +var + r: trec; +begin + r.w:=$1234; + if test(r)<>$34 then + halt(1); + if r.w<>$12 then + halt(2); +end.