diff --git a/src/mapleall/maple_be/include/cg/aarch64/aarch64_prop.h b/src/mapleall/maple_be/include/cg/aarch64/aarch64_prop.h index 551b2dfad8cb14c90b46313f7045c2315842c3b1..d59e5f2802422d85c230b4ce6bace2362accfa50 100644 --- a/src/mapleall/maple_be/include/cg/aarch64/aarch64_prop.h +++ b/src/mapleall/maple_be/include/cg/aarch64/aarch64_prop.h @@ -468,6 +468,7 @@ class A64PregCopyPattern : public PropOptimizePattern { bool CheckValidDefInsn(const Insn *defInsn); bool CheckMultiUsePoints(const Insn *defInsn) const; bool CheckPhiCaseCondition(Insn &defInsn); + bool HasValidDefInsnDependency(); bool DFSFindValidDefInsns(Insn *curDefInsn, std::vector &visitedPhiDefs, std::unordered_map &visited); Insn &CreateNewPhiInsn(std::unordered_map &newPhiList, Insn *curInsn); diff --git a/src/mapleall/maple_be/src/cg/aarch64/aarch64_prop.cpp b/src/mapleall/maple_be/src/cg/aarch64/aarch64_prop.cpp index 619821c67dc4381dbd747a822e5fd985f074a4f1..108efd00f0dbb4bf6b69e530285da4ee7d1270e2 100644 --- a/src/mapleall/maple_be/src/cg/aarch64/aarch64_prop.cpp +++ b/src/mapleall/maple_be/src/cg/aarch64/aarch64_prop.cpp @@ -2515,6 +2515,28 @@ bool A64PregCopyPattern::CheckMultiUsePoints(const Insn *defInsn) const { return true; } +bool A64PregCopyPattern::HasValidDefInsnDependency() { + /* Look for reg dependency between validDefInsns */ + for (auto *ti : validDefInsns) { + const auto *md = &AArch64CG::kMd[ti->GetMachineOpcode()]; + for (uint32 i = 0; i < ti->GetOperandSize(); i++) { + if (ti->GetOperand(i).IsRegister() && md->GetOpndDes(i)->IsRegUse() && + static_cast(ti->GetOperand(i)).IsVirtualRegister()) { + regno_t regno = static_cast(ti->GetOperand(i)).GetRegisterNumber(); + VRegVersion *useVersion = optSsaInfo->FindSSAVersion(regno); + Insn *def = FindDefInsn(useVersion); + if (def) { + auto it = find(validDefInsns.begin(), validDefInsns.end(), def); + if (it != validDefInsns.end()) { + return true; + } + } + } + } + } + return false; +} + bool A64PregCopyPattern::CheckPhiCaseCondition(Insn &defInsn) { std::unordered_map visited; std::vector visitedPhiDefs; @@ -2576,6 +2598,9 @@ bool A64PregCopyPattern::CheckPhiCaseCondition(Insn &defInsn) { if (differIdx == -1) { return false; } + if (HasValidDefInsnDependency()) { + return false; + } return true; }