From 9b54588d75372d25f022459da9bfe131e7a23795 Mon Sep 17 00:00:00 2001 From: florian Date: Mon, 18 May 2020 21:28:45 +0000 Subject: [PATCH] + PXorPXor2PXor optimization git-svn-id: trunk@45430 - --- compiler/i386/aoptcpu.pas | 3 +++ compiler/x86/aoptx86.pas | 29 +++++++++++++++++++++++++++++ compiler/x86_64/aoptcpu.pas | 3 +++ 3 files changed, 35 insertions(+) diff --git a/compiler/i386/aoptcpu.pas b/compiler/i386/aoptcpu.pas index 0c63d76781..b6d5da1eb0 100644 --- a/compiler/i386/aoptcpu.pas +++ b/compiler/i386/aoptcpu.pas @@ -141,6 +141,9 @@ unit aoptcpu; Result:=OptPass1And(p); A_CMP: Result:=OptPass1Cmp(p); + A_VPXOR, + A_PXOR: + Result:=OptPass1PXor(p); A_FLD: Result:=OptPass1FLD(p); A_FSTP,A_FISTP: diff --git a/compiler/x86/aoptx86.pas b/compiler/x86/aoptx86.pas index 2080b38058..8cb21652af 100644 --- a/compiler/x86/aoptx86.pas +++ b/compiler/x86/aoptx86.pas @@ -130,6 +130,7 @@ unit aoptx86; function OptPass1FSTP(var p : tai) : boolean; function OptPass1FLD(var p : tai) : boolean; function OptPass1Cmp(var p : tai) : boolean; + function OptPass1PXor(var p : tai) : boolean; function OptPass2MOV(var p : tai) : boolean; function OptPass2Imul(var p : tai) : boolean; @@ -3949,6 +3950,34 @@ unit aoptx86; end; + function TX86AsmOptimizer.OptPass1PXor(var p: tai): boolean; + var + hp1: tai; + begin + { + remove the second (v)pxor from + + (v)pxor reg,reg + ... + (v)pxor reg,reg + } + Result:=false; + if MatchOperand(taicpu(p).oper[0]^,taicpu(p).oper[1]^) and + MatchOpType(taicpu(p),top_reg,top_reg) and + GetNextInstructionUsingReg(p,hp1,taicpu(p).oper[0]^.reg) and + MatchInstruction(taicpu(hp1),taicpu(p).opcode,[taicpu(p).opsize]) and + MatchOperand(taicpu(p).oper[0]^,taicpu(hp1).oper[0]^) and + MatchOperand(taicpu(hp1).oper[0]^,taicpu(hp1).oper[1]^) then + begin + DebugMsg(SPeepholeOptimization + 'PXorPXor2PXor done',hp1); + asml.Remove(hp1); + hp1.Free; + Result:=true; + Exit; + end; + end; + + function TX86AsmOptimizer.OptPass2MOV(var p : tai) : boolean; function IsXCHGAcceptable: Boolean; inline; diff --git a/compiler/x86_64/aoptcpu.pas b/compiler/x86_64/aoptcpu.pas index be4d83d683..26403a7a6d 100644 --- a/compiler/x86_64/aoptcpu.pas +++ b/compiler/x86_64/aoptcpu.pas @@ -127,6 +127,9 @@ uses result:=OptPass1FLD(p); A_CMP: result:=OptPass1Cmp(p); + A_VPXOR, + A_PXOR: + Result:=OptPass1PXor(p); else ; end;