[PATCH] D116115: AMDGPU/GlobalISel: Rework legalization for extract/insert vector elt
Petar Avramovic via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 10 04:25:02 PST 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd9d2516aafb9: AMDGPU/GlobalISel: Rework legalization for extract/insert vector elt (authored by Petar.Avramovic).
Changed prior to commit:
https://reviews.llvm.org/D116115?vs=395696&id=398571#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D116115/new/
https://reviews.llvm.org/D116115
Files:
llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
Index: llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
@@ -2213,10 +2213,12 @@
LLT EltTy = VecTy.getElementType();
assert(EltTy == MRI.getType(Dst));
- if (IdxVal < VecTy.getNumElements())
- B.buildExtract(Dst, Vec, IdxVal * EltTy.getSizeInBits());
- else
+ if (IdxVal < VecTy.getNumElements()) {
+ auto Unmerge = B.buildUnmerge(EltTy, Vec);
+ B.buildCopy(Dst, Unmerge.getReg(IdxVal));
+ } else {
B.buildUndef(Dst);
+ }
MI.eraseFromParent();
return true;
@@ -2246,10 +2248,18 @@
LLT EltTy = VecTy.getElementType();
assert(EltTy == MRI.getType(Ins));
- if (IdxVal < VecTy.getNumElements())
- B.buildInsert(Dst, Vec, Ins, IdxVal * EltTy.getSizeInBits());
- else
+ unsigned NumElts = VecTy.getNumElements();
+ if (IdxVal < NumElts) {
+ SmallVector<Register, 8> SrcRegs;
+ for (unsigned i = 0; i < NumElts; ++i)
+ SrcRegs.push_back(MRI.createGenericVirtualRegister(EltTy));
+ B.buildUnmerge(SrcRegs, Vec);
+
+ SrcRegs[IdxVal] = MI.getOperand(2).getReg();
+ B.buildMerge(Dst, SrcRegs);
+ } else {
B.buildUndef(Dst);
+ }
MI.eraseFromParent();
return true;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116115.398571.patch
Type: text/x-patch
Size: 1304 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220110/b89d71a8/attachment.bin>
More information about the llvm-commits
mailing list