Browse Source

* AVR: fix TAoptBaseCpu.RegModifiedByInstruction, resolves #39623

florian 3 years ago
parent
commit
49edb0b606
1 changed files with 10 additions and 1 deletions
  1. 10 1
      compiler/avr/aoptcpub.pas

+ 10 - 1
compiler/avr/aoptcpub.pas

@@ -117,13 +117,22 @@ Implementation
       i : Longint;
     begin
       result:=false;
-      If (p1.typ = ait_instruction) and (taicpu(p1).opcode in [A_MUL,A_MULS,A_FMUL,A_FMULS,A_FMULSU]) and
+      if p1.typ <> ait_instruction then
+        exit;
+      If (taicpu(p1).opcode in [A_MUL,A_MULS,A_FMUL,A_FMULS,A_FMULSU]) and
               ((getsupreg(reg)=RS_R0) or (getsupreg(reg)=RS_R1)) then
         begin
           Result:=true;
           exit;
         end;
 
+      If (taicpu(p1).opcode=A_MOVW) and
+        (TRegister(ord(taicpu(p1).oper[0]^.reg)+1)=reg) then
+        begin
+          Result:=true;
+          exit;
+        end;
+
       for i:=0 to taicpu(p1).ops-1 do
         if (taicpu(p1).oper[i]^.typ=top_reg) and (taicpu(p1).oper[i]^.reg=Reg) and (taicpu(p1).spilling_get_operation_type(i) in [operand_write,operand_readwrite]) then
           begin