if (taicpu(p).condition <> C_None) and
(taicpu(p).oper[0]^.typ = top_ref) and
GetNextInstruction(p, hp1) and
{ Check individually instead of using MatchInstruction in order to save time }
(hp1.typ = ait_instruction) and
(taicpu(hp1).condition = C_None) and
(taicpu(hp1).oppostfix = PF_None) and
(taicpu(hp1).ops = 2) and
(
(
(taicpu(hp1).opcode = A_MOVZ) and
(taicpu(hp1).oper[1]^.val in [0, 1])
) or
(
(taicpu(hp1).opcode = A_MOV) and
(getsupreg(taicpu(hp1).oper[1]^.reg) = RS_XZR)
)
) and
GetNextInstruction(hp1, hp2) and
MatchInstruction(hp2, A_B, [PF_None]) and
(taicpu(hp2).condition = C_None) and
(taicpu(hp2).oper[0]^.typ = top_ref) and
GetNextInstruction(hp2, hp3) and
(hp3.typ = ait_label) and
(tasmlabel(taicpu(p).oper[0]^.ref^.symbol) = tai_label(hp3).labsym) and
GetNextInstruction(hp3, hp4) and
{ As before, check individually instead of using MatchInstruction in order to save time }
(hp4.typ = ait_instruction) and
(taicpu(hp4).condition = C_None) and
(taicpu(hp4).oppostfix = PF_None) and
(taicpu(hp4).ops = 2) and
(taicpu(hp4).oper[0]^.reg = taicpu(hp1).oper[0]^.reg) and
(
(
(taicpu(hp4).opcode = A_MOVZ) and
(
(
{ Check to confirm the following:
- First mov is either "movz reg,#0" or "mov reg,xzr"
- Second mov is "movz reg,#1"
}
(
(taicpu(hp1).oper[1]^.typ = top_reg) { Will be the zero register } or
(taicpu(hp1).oper[1]^.val = 0)
) and
(taicpu(hp4).oper[1]^.val = 1)
) or
(
{ Check to confirm the following:
- First mov is "movz reg,#1"
- Second mov is "movz reg,#0"
}
MatchOperand(taicpu(hp1).oper[1]^, 1) and
(taicpu(hp4).oper[1]^.val = 0)
)
)
) or
(
{ Check to confirm the following:
- First mov is "movz reg,#1"
- Second mov is "mov reg,xzr"
}
(taicpu(hp4).opcode = A_MOV) and
(getsupreg(taicpu(hp4).oper[1]^.reg) = RS_XZR) and
MatchOperand(taicpu(hp1).oper[1]^, 1)
)
) and
GetNextInstruction(hp4, hp5) and
(hp5.typ = ait_label) and
(tasmlabel(taicpu(hp2).oper[0]^.ref^.symbol) = tai_label(hp5).labsym) then
begin
Invert := MatchOperand(taicpu(hp1).oper[1]^, 1); { if true, hp4 will be mov reg,0 in some form }
if Invert then
taicpu(p).condition := inverse_cond(taicpu(p).condition);
tai_label(hp3).labsym.DecRefs;