Browse Source

Add sign extension to 32-bit for unaligned OS_8 and OS_16 types (to try to solve #40102)

Pierre Muller 2 years ago
parent
commit
4793447be1
1 changed files with 4 additions and 0 deletions
  1. 4 0
      compiler/aarch64/cgcpu.pas

+ 4 - 0
compiler/aarch64/cgcpu.pas

@@ -1003,6 +1003,10 @@ implementation
                       a_load_ref_reg(list,OS_8,OS_32,href,tmpreg2);
                       a_load_ref_reg(list,OS_8,OS_32,href,tmpreg2);
                       list.concat(taicpu.op_reg_reg_const_const(A_BFI,tmpreg,tmpreg2,i*8,8));
                       list.concat(taicpu.op_reg_reg_const_const(A_BFI,tmpreg,tmpreg2,i*8,8));
                     end;
                     end;
+                  if (tosize in [OS_S8,OS_S16]) then
+                    list.concat(taicpu.op_reg_reg(A_SXTH,tmpreg,tmpreg))
+                  else if (tosize in [OS_8,OS_16]) then
+                    list.concat(taicpu.op_reg_reg(A_UXTH,tmpreg,tmpreg));
                   a_load_reg_reg(list,fromsize,tosize,tmpreg,register);
                   a_load_reg_reg(list,fromsize,tosize,tmpreg,register);
                 end;
                 end;
             end;
             end;