[llvm] [GISel] Use SmallVector::append instead of copying one element at a time. (PR #119321)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 9 20:12:26 PST 2024
https://github.com/topperc created https://github.com/llvm/llvm-project/pull/119321
None
>From 1b5292aaaa426a7d939847e30bae94ede286a5e5 Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Mon, 9 Dec 2024 20:11:37 -0800
Subject: [PATCH] [GISel] Use SmallVector::append instead of copying one
element at a time.
---
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
index cf835ad187f818..a5b5eb7c35ccf9 100644
--- a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
@@ -182,9 +182,8 @@ void LegalizerHelper::insertParts(Register DstReg,
// Merge sub-vectors with different number of elements and insert into DstReg.
if (ResultTy.isVector()) {
assert(LeftoverRegs.size() == 1 && "Expected one leftover register");
- SmallVector<Register, 8> AllRegs;
- for (auto Reg : concat<const Register>(PartRegs, LeftoverRegs))
- AllRegs.push_back(Reg);
+ SmallVector<Register, 8> AllRegs(PartRegs.begin(), PartRegs.end());
+ AllRegs.append(LeftoverRegs.begin(), LeftoverRegs.end());
return mergeMixedSubvectors(DstReg, AllRegs);
}
@@ -6397,10 +6396,8 @@ LegalizerHelper::narrowScalarAddSub(MachineInstr &MI, unsigned TypeIdx,
MRI);
int NarrowParts = Src1Regs.size();
- for (int I = 0, E = Src1Left.size(); I != E; ++I) {
- Src1Regs.push_back(Src1Left[I]);
- Src2Regs.push_back(Src2Left[I]);
- }
+ Src1Regs.append(Src1Left);
+ Src2Regs.append(Src2Left);
DstRegs.reserve(Src1Regs.size());
for (int i = 0, e = Src1Regs.size(); i != e; ++i) {
@@ -6570,8 +6567,7 @@ LegalizerHelper::narrowScalarInsert(MachineInstr &MI, unsigned TypeIdx,
extractParts(MI.getOperand(1).getReg(), RegTy, NarrowTy, LeftoverTy, SrcRegs,
LeftoverRegs, MIRBuilder, MRI);
- for (Register Reg : LeftoverRegs)
- SrcRegs.push_back(Reg);
+ SrcRegs.append(LeftoverRegs);
uint64_t NarrowSize = NarrowTy.getSizeInBits();
Register OpReg = MI.getOperand(2).getReg();
More information about the llvm-commits
mailing list