[PATCH] Add a target legalize hook for SplitVectorOperand
Justin Holewinski
justin.holewinski at gmail.com
Mon Jul 22 18:03:05 PDT 2013
To be more specific, the X86 target declares that v2i64 extract_vector_elt
needs to be custom lowered:
if (Subtarget->is64Bit()) {
setOperationAction(ISD::INSERT_VECTOR_ELT, MVT::v2i64, Custom);
setOperationAction(ISD::EXTRACT_VECTOR_ELT, MVT::v2i64, Custom);
}
But if the element type is i64 and the index is constant, then its lowered
to itself:
if (VT == MVT::i32 || VT == MVT::i64) {
// ExtractPS/pextrq works with constant index.
if (isa<ConstantSDNode>(Op.getOperand(1)))
return Op;
}
Since this is specific to SSE 4.1, I could always add "-mattr=-sse41" to
the run line, but that would make the test X86-specific.
On Mon, Jul 22, 2013 at 8:50 PM, Justin Holewinski <
justin.holewinski at gmail.com> wrote:
> Unfortunately, it's not my lowering code. This change triggers a
> legalization loop in CodeGen/Generic/2009-03-29-SoftFloatVectorExtract.ll
> when X86 is used as the default. The X86 target lowers an i64
> extract_vector_elt to itself, causing the loop. I don't know enough about
> the X86 custom lowering code to know where to start looking. I'll see if I
> can identify the issue.
> On Jul 22, 2013 6:05 PM, "Eli Friedman" <eli.friedman at gmail.com> wrote:
>
>> On Mon, Jul 22, 2013 at 10:10 AM, Justin Holewinski
>> <justin.holewinski at gmail.com> wrote:
>> > 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;
>>
>> Please fix your custom lowering implementation...
>>
>> > // 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:
>>
>> This looks fine.
>>
>> -Eli
>>
>
--
Thanks,
Justin Holewinski
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130722/ed37feef/attachment.html>
More information about the llvm-commits
mailing list