ソースを参照

* factored out left/right swapping code in smallset operations
* force the left operand into a register if both the left and
right are constants (can happen because not all set add-nodes
are handled in taddnode.simplify) because the code below
expects at least one register operand. Fixes the compilation of a.o.
taddset2 with -O3 on ppc (constant propagagation -> 2 constant
operands)

git-svn-id: trunk@27607 -

Jonas Maebe 11 年 前
コミット
e0a910e813
1 ファイル変更12 行追加13 行削除
  1. 12 13
      compiler/ppcgen/ngppcadd.pas

+ 12 - 13
compiler/ppcgen/ngppcadd.pas

@@ -442,11 +442,18 @@ implementation
           setbase:=tsetdef(left.resultdef).setbase
           setbase:=tsetdef(left.resultdef).setbase
         else
         else
           setbase:=tsetdef(right.resultdef).setbase;
           setbase:=tsetdef(right.resultdef).setbase;
+        if (nf_swapped in flags) and
+           ((nodetype=subn) or
+            (left.nodetype=setelementn)) then
+          swapleftright;
+        { we don't support two constant locations (should ideally be handled
+          in simplify }
+        if (left.location.loc=LOC_CONSTANT) and
+           (right.location.loc=LOC_CONSTANT) then
+          hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,true);
         case nodetype of
         case nodetype of
           addn :
           addn :
             begin
             begin
-              if (nf_swapped in flags) and (left.nodetype=setelementn) then
-                swapleftright;
               { are we adding set elements ? }
               { are we adding set elements ? }
               if right.nodetype=setelementn then
               if right.nodetype=setelementn then
                 begin
                 begin
@@ -483,18 +490,10 @@ implementation
           subn :
           subn :
             begin
             begin
               cgop:=OP_AND;
               cgop:=OP_AND;
-              if (not(nf_swapped in flags)) then
-                if (right.location.loc=LOC_CONSTANT) then
-                  right.location.value := not(right.location.value)
-                else
-                  opdone := true
-              else if (left.location.loc=LOC_CONSTANT) then
-                left.location.value := not(left.location.value)
+              if (right.location.loc=LOC_CONSTANT) then
+                right.location.value := not(right.location.value)
               else
               else
-                 begin
-                   swapleftright;
-                   opdone := true;
-                 end;
+                opdone := true;
               if opdone then
               if opdone then
                 begin
                 begin
                   if left.location.loc = LOC_CONSTANT then
                   if left.location.loc = LOC_CONSTANT then