[llvm] r356107 - [AArch64][GlobalISel] Gardening: Simplify subregister copy in selectBuildVector
Jessica Paquette via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 13 16:29:54 PDT 2019
Author: paquette
Date: Wed Mar 13 16:29:54 2019
New Revision: 356107
URL: http://llvm.org/viewvc/llvm-project?rev=356107&view=rev
Log:
[AArch64][GlobalISel] Gardening: Simplify subregister copy in selectBuildVector
NFC. Some more preliminary factoring for G_INSERT_VECTOR_ELT.
Also better code-reuse, etc., etc.
Differential Revision: https://reviews.llvm.org/D59323
Modified:
llvm/trunk/lib/Target/AArch64/AArch64InstructionSelector.cpp
Modified: llvm/trunk/lib/Target/AArch64/AArch64InstructionSelector.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64InstructionSelector.cpp?rev=356107&r1=356106&r2=356107&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64InstructionSelector.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64InstructionSelector.cpp Wed Mar 13 16:29:54 2019
@@ -2383,28 +2383,24 @@ bool AArch64InstructionSelector::selectB
// 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();
More information about the llvm-commits
mailing list