Browse Source

* x86-64 uses OptPass1MOV

git-svn-id: trunk@33931 -
florian 9 năm trước cách đây
mục cha
commit
4758271c91
1 tập tin đã thay đổi với 1 bổ sung136 xóa
  1. 1 136
      compiler/x86_64/aoptcpu.pas

+ 1 - 136
compiler/x86_64/aoptcpu.pas

@@ -153,142 +153,7 @@ begin
                         taicpu(p).opcode := A_TEST;*)
           end;
         A_MOV:
-        { removes superfluous And's after mov's }
-          begin
-            if not(cs_opt_level3 in current_settings.optimizerswitches) then
-              exit;
-            GetNextIntruction_p:=GetNextInstruction(p, hp1);
-            if (taicpu(p).oper[1]^.typ = top_reg) and
-               GetNextIntruction_p and
-               (tai(hp1).typ = ait_instruction) and
-               (taicpu(hp1).opcode = A_AND) and
-               (taicpu(hp1).oper[0]^.typ = top_const) and
-               (taicpu(hp1).oper[1]^.typ = top_reg) and
-               (taicpu(hp1).oper[1]^.reg = taicpu(p).oper[1]^.reg) then
-              case taicpu(p).opsize Of
-                S_L:
-                  if (taicpu(hp1).oper[0]^.val = $ffffffff) then
-                    begin
-                      if (cs_asm_source in current_settings.globalswitches) then
-                        asml.insertbefore(tai_comment.create(strpnew('PeepHole Optimization,var2a')),p);
-                      asml.remove(hp1);
-                      hp1.free;
-                    end;
-              end
-            { Next instruction is also a MOV ? }
-            else if GetNextIntruction_p and
-              MatchInstruction(hp1,A_MOV,[taicpu(p).opsize]) then
-              begin
-                if (taicpu(hp1).oper[0]^.typ = taicpu(p).oper[1]^.typ) and
-                   (taicpu(hp1).oper[1]^.typ = taicpu(p).oper[0]^.typ) then
-                    {mov reg1, mem1     or     mov mem1, reg1
-                     mov mem2, reg2            mov reg2, mem2}
-                  begin
-                    if OpsEqual(taicpu(hp1).oper[1]^,taicpu(p).oper[0]^) then
-                      {mov reg1, mem1     or     mov mem1, reg1
-                       mov mem2, reg1            mov reg2, mem1}
-                      begin
-                        if OpsEqual(taicpu(hp1).oper[0]^,taicpu(p).oper[1]^) then
-                          { Removes the second statement from
-                            mov reg1, mem1/reg2
-                            mov mem1/reg2, reg1 }
-                          begin
-                            { if (taicpu(p).oper[0]^.typ = top_reg) then
-                              AllocRegBetween(asmL,taicpu(p).oper[0]^.reg,p,hp1,usedregs); }
-                            if (cs_asm_source in current_settings.globalswitches) then
-                              asml.insertbefore(tai_comment.create(strpnew('PeepHole Optimization,MovMov2Mov1')),p);
-                            asml.remove(hp1);
-                            hp1.free;
-                          end;
-                      end
-                    else if (taicpu(p).oper[1]^.typ=top_ref) and
-                      OpsEqual(taicpu(hp1).oper[0]^,taicpu(p).oper[1]^) then
-                      begin
-                        taicpu(hp1).loadreg(0,taicpu(p).oper[0]^.reg);
-                        if (cs_asm_source in current_settings.globalswitches) then
-                          asml.insertbefore(tai_comment.create(strpnew('PeepHole Optimization,MovMov2MovMov1')),p);
-                      end;
-                  end
-              end
-            else if (taicpu(p).oper[1]^.typ = top_reg) and
-              GetNextIntruction_p and
-              (hp1.typ = ait_instruction) and
-              GetNextInstruction(hp1, hp2) and
-              (hp2.typ = ait_instruction) and
-              (taicpu(hp2).opcode = A_MOV) and
-              (taicpu(hp2).oper[0]^.typ = top_reg) and
-              OpsEqual(taicpu(hp2).oper[1]^, taicpu(p).oper[0]^) and
-              (IsFoldableArithOp(taicpu(hp1), taicpu(p).oper[1]^.reg) or
-               ((taicpu(p).opsize=S_L) and (taicpu(hp1).opsize=S_Q) and
-                IsFoldableArithOp(taicpu(hp1), newreg(R_INTREGISTER,getsupreg(taicpu(p).oper[1]^.reg),R_SUBQ)))
-              ) then
-              { change   movsX/movzX    reg/ref, reg2             }
-              {          add/sub/or/... reg3/$const, reg2         }
-              {          mov            reg2 reg/ref              }
-              { to       add/sub/or/... reg3/$const, reg/ref      }
-              begin
-                CopyUsedRegs(TmpUsedRegs);
-                UpdateUsedRegs(TmpUsedRegs, tai(p.next));
-                UpdateUsedRegs(TmpUsedRegs, tai(hp1.next));
-                If not(RegUsedAfterInstruction(taicpu(p).oper[1]^.reg,hp2,TmpUsedRegs)) then
-                  begin
-                    { by example:
-                        movswl  %si,%eax        movswl  %si,%eax      p
-                        decl    %eax            addl    %edx,%eax     hp1
-                        movw    %ax,%si         movw    %ax,%si       hp2
-                      ->
-                        movswl  %si,%eax        movswl  %si,%eax      p
-                        decw    %eax            addw    %edx,%eax     hp1
-                        movw    %ax,%si         movw    %ax,%si       hp2
-                    }
-                    if (cs_asm_source in current_settings.globalswitches) then
-                      begin
-                        asml.insertbefore(tai_comment.create(strpnew('PeepHole Optimization,var2')),p);
-                        asml.insertbefore(tai_comment.create(strpnew('P='+std_op2str[taicpu(p).opcode]+gas_opsize2str[taicpu(p).opsize])),p);
-                        asml.insertbefore(tai_comment.create(strpnew('HP1='+std_op2str[taicpu(hp1).opcode]+gas_opsize2str[taicpu(hp1).opsize])),p);
-                        asml.insertbefore(tai_comment.create(strpnew('HP2='+std_op2str[taicpu(hp2).opcode]+gas_opsize2str[taicpu(hp2).opsize])),p);
-                     end;
-                    taicpu(hp1).changeopsize(taicpu(p).opsize);
-                    {
-                      ->
-                        movswl  %si,%eax        movswl  %si,%eax      p
-                        decw    %si             addw    %dx,%si       hp1
-                        movw    %ax,%si         movw    %ax,%si       hp2
-                    }
-                    case taicpu(hp1).ops of
-                      1:
-                        begin
-                          taicpu(hp1).loadoper(0, taicpu(hp2).oper[1]^);
-                          if taicpu(hp1).oper[0]^.typ=top_reg then
-                            setsubreg(taicpu(hp1).oper[0]^.reg,getsubreg(taicpu(p).oper[1]^.reg));
-                        end;
-                      2:
-                        begin
-                          taicpu(hp1).loadoper(1, taicpu(hp2).oper[1]^);
-                          if (taicpu(hp1).oper[0]^.typ=top_reg) and
-                            (taicpu(hp1).opcode<>A_SHL) and
-                            (taicpu(hp1).opcode<>A_SHR) and
-                            (taicpu(hp1).opcode<>A_SAR) then
-                            setsubreg(taicpu(hp1).oper[0]^.reg,getsubreg(taicpu(p).oper[1]^.reg));
-                        end;
-                      else
-                        internalerror(2008042701);
-                    end;
-                    {
-                      ->
-                        decw    %si             addw    %dx,%si       p
-                    }
-                    if (cs_asm_source in current_settings.globalswitches) then
-                      asml.insertbefore(tai_comment.create(strpnew('PeepHole Optimization,var2')),p);
-                    asml.remove(p);
-                    asml.remove(hp2);
-                    p.Free;
-                    hp2.Free;
-                    p := hp1;
-                 end;
-                ReleaseUsedRegs(TmpUsedRegs);
-              end
-          end;
+          Result:=OptPass1MOV(p);
         A_MOVSX,
         A_MOVZX:
           begin