Skip to content

Commit

Permalink
[AArch64][GlobalISel] Gardening: Simplify subregister copy in selectB…
Browse files Browse the repository at this point in the history
…uildVector

NFC. Some more preliminary factoring for G_INSERT_VECTOR_ELT.

Also better code-reuse, etc., etc.

Differential Revision: https://reviews.llvm.org/D59323

llvm-svn: 356107
  • Loading branch information
Jessica Paquette committed Mar 13, 2019
1 parent 16d67a3 commit 85ace62
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp
Expand Up @@ -2383,28 +2383,24 @@ bool AArch64InstructionSelector::selectBuildVector(
// If DstTy's size in bits is less than 128, then emit a subregister copy
// from DstVec to the last register we've defined.
if (DstSize < 128) {
unsigned SubReg = 0;

// Helper lambda to decide on a register class and subregister for the
// subregister copy.
auto GetRegInfoForCopy = [&SubReg,
&DstSize]() -> const TargetRegisterClass * {
switch (DstSize) {
default:
LLVM_DEBUG(dbgs() << "Unknown destination size (" << DstSize << ")\n");
return nullptr;
case 32:
SubReg = AArch64::ssub;
return &AArch64::FPR32RegClass;
case 64:
SubReg = AArch64::dsub;
return &AArch64::FPR64RegClass;
}
};

const TargetRegisterClass *RC = GetRegInfoForCopy();
// Force this to be FPR using the destination vector.
const TargetRegisterClass *RC =
getMinClassForRegBank(*RBI.getRegBank(DstVec, MRI, TRI), DstSize);
if (!RC)
return false;
if (RC != &AArch64::FPR32RegClass && RC != &AArch64::FPR64RegClass) {
LLVM_DEBUG(dbgs() << "Unsupported register class!\n");
return false;
}

unsigned SubReg = 0;
if (!getSubRegForClass(RC, TRI, SubReg))
return false;
if (SubReg != AArch64::ssub && SubReg != AArch64::dsub) {
LLVM_DEBUG(dbgs() << "Unsupported destination size! (" << DstSize
<< "\n");
return false;
}

unsigned Reg = MRI.createVirtualRegister(RC);
unsigned DstReg = I.getOperand(0).getReg();
Expand Down

0 comments on commit 85ace62

Please sign in to comment.