[PATCH] D59323: [AArch64][GlobalISel] Gardening: Simplify subregister copy in selectBuildVector
Jessica Paquette via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 13 13:44:42 PDT 2019
paquette created this revision.
paquette added a reviewer: aemerson.
Herald added subscribers: Petar.Avramovic, hiraditya, kristof.beyls, javed.absar, rovka.
Herald added a project: LLVM.
NFC.
Some more preliminary factoring for G_INSERT_VECTOR_ELT. The lambda there can be replaced by existing functions. We'll need the same code for G_INSERT_VECTOR_ELT, so this will allow us to avoid copying/pasting the lambda.
https://reviews.llvm.org/D59323
Files:
llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp
Index: llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp
===================================================================
--- llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp
+++ llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp
@@ -2359,28 +2359,24 @@
// 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();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59323.190492.patch
Type: text/x-patch
Size: 1846 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190313/61d61d01/attachment.bin>
More information about the llvm-commits
mailing list