+ RiscV: AndiAddwi02Andi optimization

This commit is contained in:
florian 2024-09-24 22:33:53 +02:00
parent 7c023d33d0
commit 2123c59941

View File

@ -380,8 +380,9 @@ implementation
}
if (taicpu(p).ops=3) and
(taicpu(p).oper[2]^.typ=top_const) and
GetNextInstructionUsingReg(p, hp1, taicpu(p).oper[0]^.reg) and
MatchInstruction(hp1,A_ANDI) and
GetNextInstructionUsingReg(p, hp1, taicpu(p).oper[0]^.reg) then
begin
if MatchInstruction(hp1,A_ANDI) and
(taicpu(hp1).ops=3) and
MatchOperand(taicpu(p).oper[0]^,taicpu(hp1).oper[1]^) and
(taicpu(hp1).oper[2]^.typ=top_const) and
@ -398,6 +399,26 @@ implementation
result:=true;
end
else if MatchInstruction(hp1,A_ADDIW) and
(taicpu(hp1).ops=3) and
MatchOperand(taicpu(p).oper[0]^,taicpu(hp1).oper[1]^) and
(taicpu(hp1).oper[2]^.typ=top_const) and
(taicpu(hp1).oper[2]^.val=0) and
is_imm12(taicpu(p).oper[2]^.val) and
(not RegModifiedBetween(taicpu(p).oper[1]^.reg, p,hp1)) and
RegEndOfLife(taicpu(p).oper[0]^.reg, taicpu(hp1)) then
begin
taicpu(p).loadreg(0,taicpu(hp1).oper[0]^.reg);
DebugMsg('Peephole AndiAddwi02Andi performed', hp1);
RemoveInstr(hp1);
result:=true;
end
else
result:=OptPass1OP(p);
end
else
result:=OptPass1OP(p);
end;