From f576b0c01b34f01c972e6428d47a882493b126be Mon Sep 17 00:00:00 2001 From: florian Date: Fri, 15 Apr 2016 19:27:22 +0000 Subject: [PATCH] * make use of xor reg,reg by generating it directly instead of hoping for the peephole optimizer which cannot do this properly due to missing information about flags. By doing so the size of the compiler executable gets reduced by ~1 % git-svn-id: trunk@33524 - --- compiler/i386/popt386.pas | 10 ---------- compiler/x86/cgx86.pas | 7 ++++--- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/compiler/i386/popt386.pas b/compiler/i386/popt386.pas index 34ec3bc580..2f9b5296cb 100644 --- a/compiler/i386/popt386.pas +++ b/compiler/i386/popt386.pas @@ -453,16 +453,6 @@ begin hp1.free; 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; diff --git a/compiler/x86/cgx86.pas b/compiler/x86/cgx86.pas index 229d549077..3d4f48cb34 100644 --- a/compiler/x86/cgx86.pas +++ b/compiler/x86/cgx86.pas @@ -909,9 +909,10 @@ unit cgx86; begin check_register_size(tosize,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)) + 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)); end;