Răsfoiți Sursa

* 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 -

Jonas Maebe 11 ani în urmă
părinte
comite
10ae87f11c
3 a modificat fișierele cu 29 adăugiri și 4 ștergeri
  1. 1 0
      .gitattributes
  2. 5 4
      compiler/arm/aoptcpu.pas
  3. 23 0
      tests/test/opt/tarmls1.pp

+ 1 - 0
.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

+ 5 - 4
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

+ 23 - 0
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.