Browse Source

* generate shorter code on 8-bit and 16-bit CPUs in thlcg2ll.location_force_reg,
when converting a LOC_JUMP location to a (OS_INT<x<=32)-bit reg location
(the optimization is similar to r26314, but is for non 64-bit destinations).

git-svn-id: trunk@26315 -

nickysn 11 years ago
parent
commit
f69a76b5b1
1 changed files with 11 additions and 3 deletions
  1. 11 3
      compiler/hlcg2ll.pas

+ 11 - 3
compiler/hlcg2ll.pas

@@ -1021,7 +1021,7 @@ implementation
       hl: tasmlabel;
       hl: tasmlabel;
       oldloc : tlocation;
       oldloc : tlocation;
       const_location: boolean;
       const_location: boolean;
-      dst_cgsize: tcgsize;
+      dst_cgsize,tmpsize: tcgsize;
     begin
     begin
       oldloc:=l;
       oldloc:=l;
       dst_cgsize:=def_cgsize(dst_size);
       dst_cgsize:=def_cgsize(dst_size);
@@ -1152,13 +1152,21 @@ implementation
 {$endif cpuflags}
 {$endif cpuflags}
             LOC_JUMP :
             LOC_JUMP :
               begin
               begin
+                tmpsize:=dst_cgsize;
+{$if defined(cpu8bitalu) or defined(cpu16bitalu)}
+                if TCGSize2Size[dst_cgsize]>TCGSize2Size[OS_INT] then
+                  tmpsize:=OS_INT;
+{$endif}
                 cg.a_label(list,current_procinfo.CurrTrueLabel);
                 cg.a_label(list,current_procinfo.CurrTrueLabel);
-                cg.a_load_const_reg(list,dst_cgsize,1,hregister);
+                cg.a_load_const_reg(list,tmpsize,1,hregister);
                 current_asmdata.getjumplabel(hl);
                 current_asmdata.getjumplabel(hl);
                 cg.a_jmp_always(list,hl);
                 cg.a_jmp_always(list,hl);
                 cg.a_label(list,current_procinfo.CurrFalseLabel);
                 cg.a_label(list,current_procinfo.CurrFalseLabel);
-                cg.a_load_const_reg(list,dst_cgsize,0,hregister);
+                cg.a_load_const_reg(list,tmpsize,0,hregister);
                 cg.a_label(list,hl);
                 cg.a_label(list,hl);
+{$if defined(cpu8bitalu) or defined(cpu16bitalu)}
+                cg.a_load_reg_reg(list,tmpsize,dst_cgsize,hregister,hregister);
+{$endif}
               end;
               end;
             else
             else
               begin
               begin