Browse Source

* reverse merged r33524 as it is not safe as test results showed
--- Reverse-merging r33524 into '.':
U compiler\i386\popt386.pas
U compiler\x86\cgx86.pas
--- Recording mergeinfo for reverse merge of r33524 into '.':
U .

git-svn-id: trunk@33527 -

florian 9 years ago
parent
commit
a742df9035
2 changed files with 13 additions and 4 deletions
  1. 10 0
      compiler/i386/popt386.pas
  2. 3 4
      compiler/x86/cgx86.pas

+ 10 - 0
compiler/i386/popt386.pas

@@ -453,6 +453,16 @@ begin
                           hp1.free;
                           hp1.free;
                         end;
                         end;
                 end;
                 end;
+              A_XOR:
+                if (taicpu(p).oper[0]^.typ = top_reg) and
+                   (taicpu(p).oper[1]^.typ = top_reg) and
+                   (taicpu(p).oper[0]^.reg = taicpu(p).oper[1]^.reg) then
+                 { temporarily change this to 'mov reg,0' to make it easier }
+                 { for the CSE. Will be changed back in pass 2              }
+                  begin
+                    taicpu(p).opcode := A_MOV;
+                    taicpu(p).loadConst(0,0);
+                  end;
             end;
             end;
           end;
           end;
       end;
       end;

+ 3 - 4
compiler/x86/cgx86.pas

@@ -909,10 +909,9 @@ unit cgx86;
 
 
       begin
       begin
         check_register_size(tosize,reg);
         check_register_size(tosize,reg);
-        if a=0 then
-          list.concat(taicpu.op_reg_reg(A_XOR,TCGSize2OpSize[tosize],reg,reg))
-        else
-          list.concat(taicpu.op_const_reg(A_MOV,TCGSize2OpSize[tosize],a,reg));
+        { the optimizer will change it to "xor reg,reg" when loading zero, }
+        { no need to do it here too (JM)                                   }
+        list.concat(taicpu.op_const_reg(A_MOV,TCGSize2OpSize[tosize],a,reg))
       end;
       end;