[PATCH] Add a target legalize hook for SplitVectorOperand
Justin Holewinski
justin.holewinski at gmail.com
Mon Jul 22 10:10:26 PDT 2013
CustomLowerNode was not being called during SplitVectorOperand,
meaning custom legalization could not be used by targets.
Is there a reason this is missing, or just an oversight?
This also adds a test case for NVPTX that depends on this custom
legalization.
http://llvm-reviews.chandlerc.com/D1195
Files:
lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
test/CodeGen/NVPTX/vector-stores.ll
Index: lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
+++ lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
@@ -919,6 +919,11 @@
// The target didn't want to custom lower it after all.
return false;
+ if (!LegalizeResult && Results[0].getNode() == N)
+ // The target just returned the same node, so it must not have wanted to
+ // custom lower it after all.
+ return false;
+
// Make everything that once used N's values now use those in Results instead.
assert(Results.size() == N->getNumValues() &&
"Custom lowering returned the wrong number of results!");
Index: lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
+++ lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
@@ -1031,6 +1031,10 @@
dbgs() << "\n");
SDValue Res = SDValue();
+ // See if the target wants to custom split this node.
+ if (CustomLowerNode(N, N->getOperand(OpNo).getValueType(), false))
+ return false;
+
if (Res.getNode() == 0) {
switch (N->getOpcode()) {
default:
Index: test/CodeGen/NVPTX/vector-stores.ll
===================================================================
--- /dev/null
+++ test/CodeGen/NVPTX/vector-stores.ll
@@ -0,0 +1,30 @@
+; RUN: llc < %s -march=nvptx -mcpu=sm_20 | FileCheck %s
+
+; CHECK: .visible .func foo1
+; CHECK: st.v2.f32
+define void @foo1(<2 x float> %val, <2 x float>* %ptr) {
+ store <2 x float> %val, <2 x float>* %ptr
+ ret void
+}
+
+; CHECK: .visible .func foo2
+; CHECK: st.v4.f32
+define void @foo2(<4 x float> %val, <4 x float>* %ptr) {
+ store <4 x float> %val, <4 x float>* %ptr
+ ret void
+}
+
+; CHECK: .visible .func foo3
+; CHECK: st.v2.u32
+define void @foo3(<2 x i32> %val, <2 x i32>* %ptr) {
+ store <2 x i32> %val, <2 x i32>* %ptr
+ ret void
+}
+
+; CHECK: .visible .func foo4
+; CHECK: st.v4.u32
+define void @foo4(<4 x i32> %val, <4 x i32>* %ptr) {
+ store <4 x i32> %val, <4 x i32>* %ptr
+ ret void
+}
+
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1195.1.patch
Type: text/x-patch
Size: 2137 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130722/1f4508b6/attachment.bin>
More information about the llvm-commits
mailing list