浏览代码

+ optimization in thlcgwasm.a_load_reg_reg: don't emit any instructions when moving the same size from a register to itself

Nikolay Nikolov 1 天之前
父节点
当前提交
4ad6636f05
共有 1 个文件被更改,包括 9 次插入0 次删除
  1. 9 0
      compiler/wasm32/hlcgcpu.pas

+ 9 - 0
compiler/wasm32/hlcgcpu.pas

@@ -1435,7 +1435,16 @@ implementation
     end;
 
   procedure thlcgwasm.a_load_reg_reg(list: TAsmList; fromsize, tosize: tdef; reg1, reg2: tregister);
+    var
+      fromcgsize, tocgsize: TCgSize;
     begin
+      fromcgsize:=def_cgsize(fromsize);
+      tocgsize:=def_cgsize(tosize);
+      if (reg1=reg2) and ((fromcgsize=tocgsize) or
+                          ((fromcgsize in [OS_S32,OS_32]) and (tocgsize in [OS_S32,OS_32]) and (getsubreg(reg1)=R_SUBD)) or
+                          ((fromcgsize in [OS_S64,OS_64]) and (tocgsize in [OS_S64,OS_64]))) then
+        exit;
+
       a_load_reg_stack(list,fromsize,reg1);
       if def2regtyp(fromsize) in [R_INTREGISTER,R_ADDRESSREGISTER] then
         resize_stack_int_val(list,fromsize,tosize,false);