ソースを参照

AArch64 popt: don't replace registers with X/WZR

Most arithmetic/logica instructions don't support X/WZR as operand (since
you should use movk with the calculated constant in that case)

Resolves #39372
Jonas Maebe 3 年 前
コミット
c745ae4836
2 ファイル変更24 行追加0 行削除
  1. 2 0
      compiler/armgen/aoptarm.pas
  2. 22 0
      tests/webtbs/tw39372.pp

+ 2 - 0
compiler/armgen/aoptarm.pas

@@ -346,6 +346,8 @@ Implementation
             ) and
 {$ifdef AARCH64}
             (taicpu(p).oper[1]^.reg<>NR_SP) and
+            { in this case you have to transform it to movk or the like }
+            (getsupreg(taicpu(p).oper[1]^.reg)<>RS_XZR) and
 {$endif AARCH64}
             not(RegUsedBetween(taicpu(p).oper[1]^.reg,p,hp1)) then
             begin

+ 22 - 0
tests/webtbs/tw39372.pp

@@ -0,0 +1,22 @@
+{ %norun }
+{ %opt=-O-1 }
+
+{ helpers can extend type parameters if they can only be classes }
+program Arm64Peep;
+
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+
+type bob = class
+  function doInc: integer;
+end;
+
+function bob.doInc: integer;
+begin
+Result := 0;
+Inc(Result, 32);
+end;
+
+begin
+end.