Pārlūkot izejas kodu

* don't waste a register for inc/dec(<pointer>,const);

git-svn-id: trunk@11812 -
florian 17 gadi atpakaļ
vecāks
revīzija
0a8f621a6b
2 mainītis faili ar 10 papildinājumiem un 0 dzēšanām
  1. 2 0
      compiler/ncginl.pas
  2. 8 0
      compiler/node.pas

+ 2 - 0
compiler/ncginl.pas

@@ -444,6 +444,8 @@ implementation
               { when constant, just multiply the addvalue }
               { when constant, just multiply the addvalue }
               if is_constintnode(tcallparanode(tcallparanode(left).right).left) then
               if is_constintnode(tcallparanode(tcallparanode(left).right).left) then
                  addvalue:=addvalue*get_ordinal_value(tcallparanode(tcallparanode(left).right).left)
                  addvalue:=addvalue*get_ordinal_value(tcallparanode(tcallparanode(left).right).left)
+              else if is_constpointernode(tcallparanode(tcallparanode(left).right).left) then
+                 addvalue:=addvalue*tpointerconstnode(tcallparanode(tcallparanode(left).right).left).value
               else
               else
                 begin
                 begin
                   location_force_reg(current_asmdata.CurrAsmList,tcallparanode(tcallparanode(left).right).left.location,cgsize,addvalue<=1);
                   location_force_reg(current_asmdata.CurrAsmList,tcallparanode(tcallparanode(left).right).left.location,cgsize,addvalue<=1);

+ 8 - 0
compiler/node.pas

@@ -460,6 +460,7 @@ interface
     function is_constboolnode(p : tnode) : boolean;
     function is_constboolnode(p : tnode) : boolean;
     function is_constenumnode(p : tnode) : boolean;
     function is_constenumnode(p : tnode) : boolean;
     function is_constwidecharnode(p : tnode) : boolean;
     function is_constwidecharnode(p : tnode) : boolean;
+    function is_constpointernode(p : tnode) : boolean;
 
 
 
 
 implementation
 implementation
@@ -670,6 +671,13 @@ implementation
          is_constenumnode:=(p.nodetype=ordconstn) and (p.resultdef.typ=enumdef);
          is_constenumnode:=(p.nodetype=ordconstn) and (p.resultdef.typ=enumdef);
       end;
       end;
 
 
+
+    function is_constpointernode(p : tnode) : boolean;
+      begin
+         is_constpointernode:=(p.nodetype=pointerconstn);
+      end;
+
+
 {****************************************************************************
 {****************************************************************************
                                  TNODE
                                  TNODE
  ****************************************************************************}
  ****************************************************************************}