From 66ff7a928c665e8524160da6004bbd98e0889e0b Mon Sep 17 00:00:00 2001 From: florian Date: Wed, 8 Mar 2023 22:54:17 +0100 Subject: [PATCH] + added debug messages --- compiler/x86/aoptx86.pas | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/compiler/x86/aoptx86.pas b/compiler/x86/aoptx86.pas index 278742c52e..13f8b9e597 100644 --- a/compiler/x86/aoptx86.pas +++ b/compiler/x86/aoptx86.pas @@ -1555,6 +1555,8 @@ unit aoptx86; l : TCGInt; begin result:=false; + if not(GetNextInstruction(p, hp1)) then + exit; { changes the code sequence shr/sar const1, x shl const2, x @@ -1562,9 +1564,8 @@ unit aoptx86; to either "sar/and", "shl/and" or just "and" depending on const1 and const2 } - if GetNextInstruction(p, hp1) and + if (taicpu(p).oper[0]^.typ = top_const) and MatchInstruction(hp1,A_SHL,[]) and - (taicpu(p).oper[0]^.typ = top_const) and (taicpu(hp1).oper[0]^.typ = top_const) and (taicpu(hp1).opsize = taicpu(p).opsize) and (taicpu(hp1).oper[1]^.typ = taicpu(p).oper[1]^.typ) and @@ -1576,6 +1577,7 @@ unit aoptx86; { shr/sar const1, %reg shl const2, %reg with const1 > const2 } + DebugMsg(SPeepholeOptimization + 'SxrShl2SxrAnd 1 done',p); taicpu(p).loadConst(0,taicpu(p).oper[0]^.val-taicpu(hp1).oper[0]^.val); taicpu(hp1).opcode := A_AND; l := (1 shl (taicpu(hp1).oper[0]^.val)) - 1; @@ -1594,6 +1596,7 @@ unit aoptx86; { shr/sar const1, %reg shl const2, %reg with const1 < const2 } + DebugMsg(SPeepholeOptimization + 'SxrShl2SxrAnd 2 done',p); taicpu(hp1).loadConst(0,taicpu(hp1).oper[0]^.val-taicpu(p).oper[0]^.val); taicpu(p).opcode := A_AND; l := (1 shl (taicpu(p).oper[0]^.val))-1; @@ -1611,6 +1614,7 @@ unit aoptx86; { shr/sar const1, %reg shl const2, %reg with const1 = const2 } + DebugMsg(SPeepholeOptimization + 'SxrShl2And done',p); taicpu(p).opcode := A_AND; l := (1 shl (taicpu(p).oper[0]^.val))-1; case taicpu(p).opsize Of