From e959e77f8ac3a5e9d0ba13b24e61ae2dac98c8dc Mon Sep 17 00:00:00 2001 From: William Chen Date: Mon, 6 Dec 2021 11:55:46 -0800 Subject: [PATCH] fix peephole0 cmp/cset use of param reg in prolog BB --- src/mapleall/maple_be/src/cg/aarch64/aarch64_peep.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/mapleall/maple_be/src/cg/aarch64/aarch64_peep.cpp b/src/mapleall/maple_be/src/cg/aarch64/aarch64_peep.cpp index 739c129837..f9b6f9edc8 100644 --- a/src/mapleall/maple_be/src/cg/aarch64/aarch64_peep.cpp +++ b/src/mapleall/maple_be/src/cg/aarch64/aarch64_peep.cpp @@ -372,7 +372,7 @@ void AArch64PrePeepHole1::Run(BB &bb, Insn &insn) { } void RemoveIdenticalLoadAndStoreAArch64::Run(BB &bb, Insn &insn) { - Insn *nextInsn = insn.GetNext(); + Insn *nextInsn = insn.GetNextMachineInsn(); if (nextInsn == nullptr) { return; } @@ -1831,6 +1831,14 @@ bool CmpCsetAArch64::OpndDefByOneValidBit(const Insn &defInsn) { * for cmp reg,#0(#1), that is checking for reg */ bool CmpCsetAArch64::CheckOpndDefPoints(Insn &checkInsn, int opndIdx) { + if (checkInsn.GetBB()->GetPrev() == nullptr) { + /* For 1st BB, be conservative for def of parameter registers */ + /* Since peep is light weight, do not want to insert pseudo defs */ + regno_t reg = static_cast(checkInsn.GetOperand(opndIdx)).GetRegisterNumber(); + if ((reg >= R0 && reg <= R7) || (reg >= D0 && reg <= D7)) { + return false; + } + } /* check current BB */ const Insn *defInsn = DefInsnOfOperandInBB(checkInsn, checkInsn, opndIdx); if (defInsn != nullptr) { -- Gitee