[PATCH] D83882: [Legalize] Hoist invariant condition in ExpandVectorBuildThroughStack(...)
Cameron McInally via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 15 08:46:14 PDT 2020
cameron.mcinally created this revision.
cameron.mcinally added reviewers: craig.topper, spatel, kparzysz, lebedev.ri.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
The operands of a BUILD_VECTOR must all have the same type, so we can hoist this invariant condition out of the loop.
I'm a little torn if this change actually helps code clarity, so would be happy to abandon it too.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D83882
Files:
llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -1411,6 +1411,12 @@
SmallVector<SDValue, 8> Stores;
unsigned TypeByteSize = MemVT.getSizeInBits() / 8;
assert(TypeByteSize > 0 && "Vector element type too small for stack store!");
+
+ // If the destination vector element type of a BUILD_VECTOR is narrower than
+ // the source element type, only store the bits necessary.
+ bool Truncate = isa<BuildVectorSDNode>(Node) &&
+ MemVT.bitsLT(Node->getOperand(0).getValueType());
+
// Store (in the right endianness) the elements to memory.
for (unsigned i = 0, e = Node->getNumOperands(); i != e; ++i) {
// Ignore undef elements.
@@ -1420,9 +1426,7 @@
SDValue Idx = DAG.getMemBasePlusOffset(FIPtr, Offset, dl);
- // If the destination vector element type is narrower than the source
- // element type, only store the bits necessary.
- if (MemVT.bitsLT(Node->getOperand(i).getValueType()))
+ if (Truncate)
Stores.push_back(DAG.getTruncStore(DAG.getEntryNode(), dl,
Node->getOperand(i), Idx,
PtrInfo.getWithOffset(Offset), MemVT));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83882.278205.patch
Type: text/x-patch
Size: 1352 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200715/c24798c6/attachment.bin>
More information about the llvm-commits
mailing list