[llvm] r277959 - [X86] lowerVectorShuffle - ensure that undefined mask elements only use SM_SentinelUndef

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 7 12:10:54 PDT 2016


Can we instead add an assertion here and in getVectorShuffle and fix any
code that breaks the rule?

On Sunday, August 7, 2016, Simon Pilgrim <llvm-dev at redking.me.uk> wrote:

> No, but we don’t seem to have a hard rule that VECTOR_SHUFFLE can only use
> (-1) to define undefined mask elements - AFAICT it can be any negative
> value. This is preventing us from sharing a number of chunks of x86 shuffle
> matching code that current use Mask[i] < 0 to match all undefineds.
>
> Simon.
>
> On 7 Aug 2016, at 16:56, Craig Topper <craig.topper at gmail.com
> <javascript:_e(%7B%7D,'cvml','craig.topper at gmail.com');>> wrote:
>
> I don't quite understand this. Does combining come through
> lowerVectorShuffle? Or when would a VECTOR_SHUFFLE come through where this
> wasn't true?
>
> On Sunday, August 7, 2016, Simon Pilgrim via llvm-commits <
> llvm-commits at lists.llvm.org
> <javascript:_e(%7B%7D,'cvml','llvm-commits at lists.llvm.org');>> wrote:
>
>> Author: rksimon
>> Date: Sun Aug  7 10:29:12 2016
>> New Revision: 277959
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=277959&view=rev
>> Log:
>> [X86] lowerVectorShuffle - ensure that undefined mask elements only use
>> SM_SentinelUndef
>>
>> Help lowering and combining (which can specify SM_SentinelZero mask
>> elements) share more shuffle matching code.
>>
>> Modified:
>>     llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
>>
>> Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X8
>> 6/X86ISelLowering.cpp?rev=277959&r1=277958&r2=277959&view=diff
>> ============================================================
>> ==================
>> --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
>> +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Sun Aug  7 10:29:12
>> 2016
>> @@ -12281,6 +12281,15 @@ static SDValue lowerVectorShuffle(SDValu
>>          return DAG.getVectorShuffle(VT, DL, V1, V2, NewMask);
>>        }
>>
>> +  // Ensure that undefined mask elements only use SM_SentinelUndef.
>> +  if (llvm::any_of(Mask, [](int M) { return M < SM_SentinelUndef; })) {
>> +    SmallVector<int, 8> NewMask(Mask.begin(), Mask.end());
>> +    for (int &M : NewMask)
>> +      if (M < SM_SentinelUndef)
>> +        M = SM_SentinelUndef;
>> +    return DAG.getVectorShuffle(VT, DL, V1, V2, NewMask);
>> +  }
>> +
>>    // We actually see shuffles that are entirely re-arrangements of a set
>> of
>>    // zero inputs. This mostly happens while decomposing complex shuffles
>> into
>>    // simple ones. Directly lower these as a buildvector of zeros.
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>
>
> --
> ~Craig
>
>
>

-- 
~Craig
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160807/351e4b9f/attachment.html>


More information about the llvm-commits mailing list