瀏覽代碼

* AArch64: fix storing a 32 bit value in the lower 32 bits of a 64 bit
subsetreg (mantis #38766)

git-svn-id: trunk@49236 -

Jonas Maebe 4 年之前
父節點
當前提交
7c9fb4b4af
共有 3 個文件被更改,包括 31 次插入1 次删除
  1. 1 0
      .gitattributes
  2. 2 1
      compiler/aarch64/hlcgcpu.pas
  3. 28 0
      tests/webtbs/tw38766.pp

+ 1 - 0
.gitattributes

@@ -18797,6 +18797,7 @@ tests/webtbs/tw3870.pp svneol=native#text/plain
 tests/webtbs/tw38703.pp svneol=native#text/pascal
 tests/webtbs/tw38718.pp svneol=native#text/pascal
 tests/webtbs/tw38733.pp svneol=native#text/pascal
+tests/webtbs/tw38766.pp svneol=native#text/plain
 tests/webtbs/tw3893.pp svneol=native#text/plain
 tests/webtbs/tw3898.pp svneol=native#text/plain
 tests/webtbs/tw3899.pp svneol=native#text/plain

+ 2 - 1
compiler/aarch64/hlcgcpu.pas

@@ -210,7 +210,8 @@ implementation
       if slopt in [SL_SETZERO,SL_SETMAX] then
         inherited
       else if not(sreg.bitlen in [32,64]) or
-              (sreg.startbit<>0) then
+              (sreg.startbit<>0) or
+              (getsubreg(fromreg)<getsubreg(sreg.subsetreg)) then
         begin
           makeregssamesize(list,def_cgsize(fromsize),sreg.subsetregsize,fromreg,sreg.subsetreg,fromreg,toreg);
           list.concat(taicpu.op_reg_reg_const_const(A_BFI,toreg,fromreg,sreg.startbit,sreg.bitlen))

+ 28 - 0
tests/webtbs/tw38766.pp

@@ -0,0 +1,28 @@
+{$mode objfpc}
+
+type
+  trec = record
+    x, y: longint;
+  end;
+
+function max(x,y: longint): longint;
+begin
+  if x>y then
+    result:=x
+  else
+    result:=y;
+end;
+
+function test: trec; inline;
+begin
+ result.x:=1;
+ result.y:=2;
+ result.x:=max(result.x,result.y);
+end;
+    
+begin
+  if test.x<>2 then
+    halt(1);
+  if test.y<>2 then
+    halt(2);
+end.