[llvm] [AArch64][GlobalISel] Avoid generating inserts for undefs when selecting G_BUILD_VECTOR (PR #84452)
Amara Emerson via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 11 10:09:07 PDT 2024
================
@@ -5934,13 +5934,16 @@ bool AArch64InstructionSelector::selectBuildVector(MachineInstr &I,
// Keep track of the last MI we inserted. Later on, we might be able to save
// a copy using it.
- MachineInstr *PrevMI = nullptr;
+ MachineInstr *PrevMI = ScalarToVec;
for (unsigned i = 2, e = DstSize / EltSize + 1; i < e; ++i) {
// Note that if we don't do a subregister copy, we can end up making an
// extra register.
- PrevMI = &*emitLaneInsert(std::nullopt, DstVec, I.getOperand(i).getReg(),
- i - 1, RB, MIB);
- DstVec = PrevMI->getOperand(0).getReg();
+ Register OpReg = I.getOperand(i).getReg();
+ // Do not emit inserts for undefs
+ if (!getOpcodeDef(TargetOpcode::G_IMPLICIT_DEF, OpReg, MRI)) {
----------------
aemerson wrote:
You can do the shorter `!isa<GImplicitDef>(OpReg, MRI)`
https://github.com/llvm/llvm-project/pull/84452
More information about the llvm-commits
mailing list