diff --git a/src/mapleall/maple_be/src/cg/aarch64/aarch64_global.cpp b/src/mapleall/maple_be/src/cg/aarch64/aarch64_global.cpp index 67e6b853d6e4f480d49bd398f21eafee81ebd636..704c4a2ea92e987f8438aba0e3ef8a8e032d698e 100644 --- a/src/mapleall/maple_be/src/cg/aarch64/aarch64_global.cpp +++ b/src/mapleall/maple_be/src/cg/aarch64/aarch64_global.cpp @@ -1198,15 +1198,17 @@ void ExtendShiftOptPattern::ReplaceUseInsn(Insn &use, Insn &def, uint32 amount) void ExtendShiftOptPattern::Optimize(Insn &insn) { if (shiftOp == BitShiftOperand::kLSL) { InsnSet preDef = cgFunc.GetRD()->FindDefForRegOpnd(*defInsn, kInsnSecondOpnd, false); - Insn *preDefInsn = *preDef.begin(); - CHECK_FATAL((preDefInsn != nullptr), "defInsn is null!"); - SelectExtenOp(*preDefInsn); - /* preDefInsn must be uxt/sxt */ - if (extendOp != ExtendShiftOperand::kUndef) { - AArch64ImmOperand &immOpnd = static_cast(defInsn->GetOperand(kInsnThirdOpnd)); - /* do pattern2 */ - ReplaceUseInsn(insn, *preDefInsn, immOpnd.GetValue()); - return; + if (preDef.size() == 1) { + Insn *preDefInsn = *preDef.begin(); + CHECK_FATAL((preDefInsn != nullptr), "defInsn is null!"); + SelectExtenOp(*preDefInsn); + /* preDefInsn must be uxt/sxt */ + if (extendOp != ExtendShiftOperand::kUndef) { + AArch64ImmOperand &immOpnd = static_cast(defInsn->GetOperand(kInsnThirdOpnd)); + /* do pattern2 */ + ReplaceUseInsn(insn, *preDefInsn, immOpnd.GetValue()); + return; + } } } /* reset shiftOp and extendOp */ @@ -1216,7 +1218,7 @@ void ExtendShiftOptPattern::Optimize(Insn &insn) { /* do pattern1 */ ReplaceUseInsn(insn, *defInsn, 0); } else if (shiftOp != BitShiftOperand::kUndef) { - /* do pattern2 */ + /* do pattern3 */ AArch64ImmOperand &immOpnd = static_cast(defInsn->GetOperand(kInsnThirdOpnd)); ReplaceUseInsn(insn, *defInsn, immOpnd.GetValue()); } else { @@ -1282,4 +1284,4 @@ void ExtendShiftOptPattern::Run() { } } } -} /* namespace maplebe */ \ No newline at end of file +} /* namespace maplebe */