14#ifndef LLVM_LIB_TARGET_AARCH64_AARCH64PERFECTSHUFFLE_H
15#define LLVM_LIB_TARGET_AARCH64_AARCH64PERFECTSHUFFLE_H
6593 assert(M.size() == 4 &&
"Expected a 4 entry perfect shuffle");
6597 return E.value() < 0 ||
E.value() == (int)
E.index();
6601 return E.value() < 0 ||
E.value() == (int)
E.index() + 4;
6607 unsigned PFIndexes[4];
6608 for (
unsigned i = 0; i != 4; ++i) {
6609 assert(M[i] < 8 &&
"Expected a maximum entry of 8 for shuffle mask");
6613 PFIndexes[i] = M[i];
6617 unsigned PFTableIndex = PFIndexes[0] * 9 * 9 * 9 + PFIndexes[1] * 9 * 9 +
6618 PFIndexes[2] * 9 + PFIndexes[3];
6621 return (PFEntry >> 30) + 1;
6630 unsigned &WhichResultOut,
unsigned &OperandOrderOut) {
6631 if (NumElts % 2 != 0)
6637 bool Result0Order0 =
true;
6638 bool Result1Order0 =
true;
6639 bool Result0Order1 =
true;
6640 bool Result1Order1 =
true;
6642 for (
unsigned i = 0; i != NumElts; i += 2) {
6645 if (EvenElt != i / 2)
6646 Result0Order0 =
false;
6647 if (EvenElt != NumElts / 2 + i / 2)
6648 Result1Order0 =
false;
6649 if (EvenElt != NumElts + i / 2)
6650 Result0Order1 =
false;
6651 if (EvenElt != NumElts + NumElts / 2 + i / 2)
6652 Result1Order1 =
false;
6654 if (M[i + 1] >= 0) {
6655 unsigned OddElt = (
unsigned)M[i + 1];
6656 if (OddElt != NumElts + i / 2)
6657 Result0Order0 =
false;
6658 if (OddElt != NumElts + NumElts / 2 + i / 2)
6659 Result1Order0 =
false;
6660 if (OddElt != i / 2)
6661 Result0Order1 =
false;
6662 if (OddElt != NumElts / 2 + i / 2)
6663 Result1Order1 =
false;
6667 if (Result0Order0 + Result1Order0 + Result0Order1 + Result1Order1 != 1)
6670 WhichResultOut = (Result0Order0 || Result0Order1) ? 0 : 1;
6671 OperandOrderOut = (Result0Order0 || Result1Order0) ? 0 : 1;
6679 unsigned &WhichResultOut) {
6681 unsigned WhichResult = 2;
6682 for (
unsigned i = 0; i != NumElts; i++) {
6684 WhichResult = ((
unsigned)M[i] == i * 2 ? 0 : 1);
6688 if (WhichResult == 2)
6692 for (
unsigned i = 0; i != NumElts; ++i) {
6695 if ((
unsigned)M[i] != 2 * i + WhichResult)
6698 WhichResultOut = WhichResult;
6708 unsigned &WhichResultOut,
unsigned &OperandOrderOut) {
6709 if (NumElts % 2 != 0)
6715 bool Result0Order0 =
true;
6716 bool Result1Order0 =
true;
6717 bool Result0Order1 =
true;
6718 bool Result1Order1 =
true;
6720 for (
unsigned i = 0; i != NumElts; i += 2) {
6724 Result0Order0 =
false;
6725 if (EvenElt != i + 1)
6726 Result1Order0 =
false;
6727 if (EvenElt != NumElts + i)
6728 Result0Order1 =
false;
6729 if (EvenElt != NumElts + i + 1)
6730 Result1Order1 =
false;
6732 if (M[i + 1] >= 0) {
6733 unsigned OddElt = (
unsigned)M[i + 1];
6734 if (OddElt != NumElts + i)
6735 Result0Order0 =
false;
6736 if (OddElt != NumElts + i + 1)
6737 Result1Order0 =
false;
6739 Result0Order1 =
false;
6740 if (OddElt != i + 1)
6741 Result1Order1 =
false;
6745 if (Result0Order0 + Result1Order0 + Result0Order1 + Result1Order1 != 1)
6748 WhichResultOut = (Result0Order0 || Result0Order1) ? 0 : 1;
6749 OperandOrderOut = (Result0Order0 || Result1Order0) ? 0 : 1;
6760 "Only possible block sizes for REV are: 16, 32, 64, 128");
6762 unsigned BlockElts = M[0] + 1;
6770 for (
unsigned i = 0; i < NumElts; ++i) {
6773 if ((
unsigned)M[i] != (i - i % BlockElts) + (BlockElts - 1 - i % BlockElts))
6783 unsigned SegmentSize) {
6787 if (SegmentSize * Segments != Mask.size())
6788 return std::nullopt;
6791 if (Lane >= SegmentSize)
6792 return std::nullopt;
6797 const unsigned SegmentIndex =
P.index() / SegmentSize;
6798 return P.value() < 0 ||
6799 unsigned(
P.value()) == Lane + SegmentIndex * SegmentSize;
6803 return std::nullopt;
6808 unsigned SegmentSize) {
6810 if (SegmentSize * Segments != Mask.size())
6816 const unsigned IndexWithinSegment =
P.index() % SegmentSize;
6817 return P.value() < 0 ||
unsigned(
P.value()) == IndexWithinSegment;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static const int BlockSize
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
This is an optimization pass for GlobalISel generic memory operations.
std::optional< unsigned > isDUPQMask(ArrayRef< int > Mask, unsigned Segments, unsigned SegmentSize)
isDUPQMask - matches a splat of equivalent lanes within segments of a given number of elements.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
bool isZIPMask(ArrayRef< int > M, unsigned NumElts, unsigned &WhichResultOut, unsigned &OperandOrderOut)
Return true for zip1 or zip2 masks of the form: <0, 8, 1, 9, 2, 10, 3, 11> (WhichResultOut = 0,...
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
bool isDUPFirstSegmentMask(ArrayRef< int > Mask, unsigned Segments, unsigned SegmentSize)
isDUPFirstSegmentMask - matches a splat of the first 128b segment.
unsigned getPerfectShuffleCost(llvm::ArrayRef< int > M)
bool isUZPMask(ArrayRef< int > M, unsigned NumElts, unsigned &WhichResultOut)
Return true for uzp1 or uzp2 masks of the form: <0, 2, 4, 6, 8, 10, 12, 14> or <1,...
bool isREVMask(ArrayRef< int > M, unsigned EltSize, unsigned NumElts, unsigned BlockSize)
isREVMask - Check if a vector shuffle corresponds to a REV instruction with the specified blocksize.
static const unsigned PerfectShuffleTable[6561+1]
bool isTRNMask(ArrayRef< int > M, unsigned NumElts, unsigned &WhichResultOut, unsigned &OperandOrderOut)
Return true for trn1 or trn2 masks of the form: <0, 8, 2, 10, 4, 12, 6, 14> (WhichResultOut = 0,...