forked from OSchip/llvm-project
[Hexagon] Recognize vdealb, vdealh, vshuffb and vshuffh specifically
llvm-svn: 319978
This commit is contained in:
parent
03ad4e7f46
commit
d2967868be
|
@ -1538,8 +1538,6 @@ OpRef HvxSelector::perfect(ShuffleMask SM, OpRef Va, ResultStack &Results) {
|
|||
// V6_vshuffvdd (V6_vshuff)
|
||||
// V6_dealvdd (V6_vdeal)
|
||||
|
||||
// TODO Recognize patterns for V6_vdeal{b,h} and V6_vshuff{b,h}.
|
||||
|
||||
int VecLen = SM.Mask.size();
|
||||
assert(isPowerOf2_32(VecLen) && Log2_32(VecLen) <= 8);
|
||||
unsigned LogLen = Log2_32(VecLen);
|
||||
|
@ -1708,6 +1706,32 @@ OpRef HvxSelector::perfect(ShuffleMask SM, OpRef Va, ResultStack &Results) {
|
|||
return NewC;
|
||||
};
|
||||
|
||||
auto pfs = [](const std::set<CycleType> &Cs, unsigned Len) {
|
||||
// Ordering: shuff: 5 0 1 2 3 4, deal: 5 4 3 2 1 0 (for Log=6),
|
||||
// for bytes zero is included, for halfwords is not.
|
||||
if (Cs.size() != 1)
|
||||
return 0u;
|
||||
const CycleType &C = *Cs.begin();
|
||||
if (C[0] != Len-1)
|
||||
return 0u;
|
||||
int D = Len - C.size();
|
||||
if (D != 0 && D != 1)
|
||||
return 0u;
|
||||
|
||||
bool IsDeal = true, IsShuff = true;
|
||||
for (unsigned I = 1; I != Len-D; ++I) {
|
||||
if (C[I] != Len-1-I)
|
||||
IsDeal = false;
|
||||
if (C[I] != I-(1-D)) // I-1, I
|
||||
IsShuff = false;
|
||||
}
|
||||
// At most one, IsDeal or IsShuff, can be non-zero.
|
||||
assert(!(IsDeal || IsShuff) || IsDeal != IsShuff);
|
||||
static unsigned Deals[] = { Hexagon::V6_vdealb, Hexagon::V6_vdealh };
|
||||
static unsigned Shufs[] = { Hexagon::V6_vshuffb, Hexagon::V6_vshuffh };
|
||||
return IsDeal ? Deals[D] : (IsShuff ? Shufs[D] : 0);
|
||||
};
|
||||
|
||||
while (!All.empty()) {
|
||||
unsigned A = *All.begin();
|
||||
All.erase(A);
|
||||
|
@ -1722,6 +1746,17 @@ OpRef HvxSelector::perfect(ShuffleMask SM, OpRef Va, ResultStack &Results) {
|
|||
Cycles.insert(canonicalize(C));
|
||||
}
|
||||
|
||||
MVT SingleTy = getSingleVT(MVT::i8);
|
||||
MVT PairTy = getPairVT(MVT::i8);
|
||||
|
||||
// Recognize patterns for V6_vdeal{b,h} and V6_vshuff{b,h}.
|
||||
if (unsigned(VecLen) == HwLen) {
|
||||
if (unsigned SingleOpc = pfs(Cycles, LogLen)) {
|
||||
Results.push(SingleOpc, SingleTy, {Va});
|
||||
return OpRef::res(Results.top());
|
||||
}
|
||||
}
|
||||
|
||||
SmallVector<unsigned,8> SwapElems;
|
||||
if (HwLen == unsigned(VecLen))
|
||||
SwapElems.push_back(LogLen-1);
|
||||
|
@ -1733,8 +1768,6 @@ OpRef HvxSelector::perfect(ShuffleMask SM, OpRef Va, ResultStack &Results) {
|
|||
SwapElems.push_back(C[0]);
|
||||
}
|
||||
|
||||
MVT SingleTy = getSingleVT(MVT::i8);
|
||||
MVT PairTy = getPairVT(MVT::i8);
|
||||
const SDLoc &dl(Results.InpNode);
|
||||
OpRef Arg = !Extend ? Va
|
||||
: concat(Va, OpRef::undef(SingleTy), Results);
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
; RUN: llc -march=hexagon < %s | FileCheck %s
|
||||
|
||||
; CHECK-LABEL: test_vdealb_64:
|
||||
; CHECK: v0.b = vdeal(v0.b)
|
||||
define <64 x i8> @test_vdealb_64(<64 x i8> %v0) #0 {
|
||||
%p = shufflevector <64 x i8> %v0, <64 x i8> undef, <64 x i32> <i32 0, i32 2, i32 4, i32 6, i32 8, i32 10, i32 12, i32 14, i32 16, i32 18, i32 20, i32 22, i32 24, i32 26, i32 28, i32 30, i32 32, i32 34, i32 36, i32 38, i32 40, i32 42, i32 44, i32 46, i32 48, i32 50, i32 52, i32 54, i32 56, i32 58, i32 60, i32 62, i32 1, i32 3, i32 5, i32 7, i32 9, i32 11, i32 13, i32 15, i32 17, i32 19, i32 21, i32 23, i32 25, i32 27, i32 29, i32 31, i32 33, i32 35, i32 37, i32 39, i32 41, i32 43, i32 45, i32 47, i32 49, i32 51, i32 53, i32 55, i32 57, i32 59, i32 61, i32 63>
|
||||
ret <64 x i8> %p
|
||||
}
|
||||
|
||||
; CHECK-LABEL: test_vdealh_64:
|
||||
; CHECK: v0.h = vdeal(v0.h)
|
||||
define <64 x i8> @test_vdealh_64(<64 x i8> %v0) #0 {
|
||||
%p = shufflevector <64 x i8> %v0, <64 x i8> undef, <64 x i32> <i32 0, i32 1, i32 4, i32 5, i32 8, i32 9, i32 12, i32 13, i32 16, i32 17, i32 20, i32 21, i32 24, i32 25, i32 28, i32 29, i32 32, i32 33, i32 36, i32 37, i32 40, i32 41, i32 44, i32 45, i32 48, i32 49, i32 52, i32 53, i32 56, i32 57, i32 60, i32 61, i32 2, i32 3, i32 6, i32 7, i32 10, i32 11, i32 14, i32 15, i32 18, i32 19, i32 22, i32 23, i32 26, i32 27, i32 30, i32 31, i32 34, i32 35, i32 38, i32 39, i32 42, i32 43, i32 46, i32 47, i32 50, i32 51, i32 54, i32 55, i32 58, i32 59, i32 62, i32 63>
|
||||
ret <64 x i8> %p
|
||||
}
|
||||
|
||||
; CHECK-LABEL: test_vshuffb_64:
|
||||
; CHECK: v0.b = vshuff(v0.b)
|
||||
define <64 x i8> @test_vshuffb_64(<64 x i8> %v0) #0 {
|
||||
%p = shufflevector <64 x i8> %v0, <64 x i8> undef, <64 x i32> <i32 0, i32 32, i32 1, i32 33, i32 2, i32 34, i32 3, i32 35, i32 4, i32 36, i32 5, i32 37, i32 6, i32 38, i32 7, i32 39, i32 8, i32 40, i32 9, i32 41, i32 10, i32 42, i32 11, i32 43, i32 12, i32 44, i32 13, i32 45, i32 14, i32 46, i32 15, i32 47, i32 16, i32 48, i32 17, i32 49, i32 18, i32 50, i32 19, i32 51, i32 20, i32 52, i32 21, i32 53, i32 22, i32 54, i32 23, i32 55, i32 24, i32 56, i32 25, i32 57, i32 26, i32 58, i32 27, i32 59, i32 28, i32 60, i32 29, i32 61, i32 30, i32 62, i32 31, i32 63>
|
||||
ret <64 x i8> %p
|
||||
}
|
||||
|
||||
; CHECK-LABEL: test_vshuffh_64:
|
||||
; CHECK: v0.h = vshuff(v0.h)
|
||||
define <64 x i8> @test_vshuffh_64(<64 x i8> %v0) #0 {
|
||||
%p = shufflevector <64 x i8> %v0, <64 x i8> undef, <64 x i32> <i32 0, i32 1, i32 32, i32 33, i32 2, i32 3, i32 34, i32 35, i32 4, i32 5, i32 36, i32 37, i32 6, i32 7, i32 38, i32 39, i32 8, i32 9, i32 40, i32 41, i32 10, i32 11, i32 42, i32 43, i32 12, i32 13, i32 44, i32 45, i32 14, i32 15, i32 46, i32 47, i32 16, i32 17, i32 48, i32 49, i32 18, i32 19, i32 50, i32 51, i32 20, i32 21, i32 52, i32 53, i32 22, i32 23, i32 54, i32 55, i32 24, i32 25, i32 56, i32 57, i32 26, i32 27, i32 58, i32 59, i32 28, i32 29, i32 60, i32 61, i32 30, i32 31, i32 62, i32 63>
|
||||
ret <64 x i8> %p
|
||||
}
|
||||
|
||||
|
||||
; CHECK-LABEL: test_vdealb_128:
|
||||
; CHECK: v0.b = vdeal(v0.b)
|
||||
define <128 x i8> @test_vdealb_128(<128 x i8> %v0) #1 {
|
||||
%p = shufflevector <128 x i8> %v0, <128 x i8> undef, <128 x i32> <i32 0, i32 2, i32 4, i32 6, i32 8, i32 10, i32 12, i32 14, i32 16, i32 18, i32 20, i32 22, i32 24, i32 26, i32 28, i32 30, i32 32, i32 34, i32 36, i32 38, i32 40, i32 42, i32 44, i32 46, i32 48, i32 50, i32 52, i32 54, i32 56, i32 58, i32 60, i32 62, i32 64, i32 66, i32 68, i32 70, i32 72, i32 74, i32 76, i32 78, i32 80, i32 82, i32 84, i32 86, i32 88, i32 90, i32 92, i32 94, i32 96, i32 98, i32 100, i32 102, i32 104, i32 106, i32 108, i32 110, i32 112, i32 114, i32 116, i32 118, i32 120, i32 122, i32 124, i32 126, i32 1, i32 3, i32 5, i32 7, i32 9, i32 11, i32 13, i32 15, i32 17, i32 19, i32 21, i32 23, i32 25, i32 27, i32 29, i32 31, i32 33, i32 35, i32 37, i32 39, i32 41, i32 43, i32 45, i32 47, i32 49, i32 51, i32 53, i32 55, i32 57, i32 59, i32 61, i32 63, i32 65, i32 67, i32 69, i32 71, i32 73, i32 75, i32 77, i32 79, i32 81, i32 83, i32 85, i32 87, i32 89, i32 91, i32 93, i32 95, i32 97, i32 99, i32 101, i32 103, i32 105, i32 107, i32 109, i32 111, i32 113, i32 115, i32 117, i32 119, i32 121, i32 123, i32 125, i32 127>
|
||||
ret <128 x i8> %p
|
||||
}
|
||||
|
||||
; CHECK-LABEL: test_vdealh_128:
|
||||
; CHECK: v0.h = vdeal(v0.h)
|
||||
define <128 x i8> @test_vdealh_128(<128 x i8> %v0) #1 {
|
||||
%p = shufflevector <128 x i8> %v0, <128 x i8> undef, <128 x i32> <i32 0, i32 1, i32 4, i32 5, i32 8, i32 9, i32 12, i32 13, i32 16, i32 17, i32 20, i32 21, i32 24, i32 25, i32 28, i32 29, i32 32, i32 33, i32 36, i32 37, i32 40, i32 41, i32 44, i32 45, i32 48, i32 49, i32 52, i32 53, i32 56, i32 57, i32 60, i32 61, i32 64, i32 65, i32 68, i32 69, i32 72, i32 73, i32 76, i32 77, i32 80, i32 81, i32 84, i32 85, i32 88, i32 89, i32 92, i32 93, i32 96, i32 97, i32 100, i32 101, i32 104, i32 105, i32 108, i32 109, i32 112, i32 113, i32 116, i32 117, i32 120, i32 121, i32 124, i32 125, i32 2, i32 3, i32 6, i32 7, i32 10, i32 11, i32 14, i32 15, i32 18, i32 19, i32 22, i32 23, i32 26, i32 27, i32 30, i32 31, i32 34, i32 35, i32 38, i32 39, i32 42, i32 43, i32 46, i32 47, i32 50, i32 51, i32 54, i32 55, i32 58, i32 59, i32 62, i32 63, i32 66, i32 67, i32 70, i32 71, i32 74, i32 75, i32 78, i32 79, i32 82, i32 83, i32 86, i32 87, i32 90, i32 91, i32 94, i32 95, i32 98, i32 99, i32 102, i32 103, i32 106, i32 107, i32 110, i32 111, i32 114, i32 115, i32 118, i32 119, i32 122, i32 123, i32 126, i32 127>
|
||||
ret <128 x i8> %p
|
||||
}
|
||||
|
||||
; CHECK-LABEL: test_vshuffb_128:
|
||||
; CHECK: v0.b = vshuff(v0.b)
|
||||
define <128 x i8> @test_vshuffb_128(<128 x i8> %v0) #1 {
|
||||
%p = shufflevector <128 x i8> %v0, <128 x i8> undef, <128 x i32> <i32 0, i32 64, i32 1, i32 65, i32 2, i32 66, i32 3, i32 67, i32 4, i32 68, i32 5, i32 69, i32 6, i32 70, i32 7, i32 71, i32 8, i32 72, i32 9, i32 73, i32 10, i32 74, i32 11, i32 75, i32 12, i32 76, i32 13, i32 77, i32 14, i32 78, i32 15, i32 79, i32 16, i32 80, i32 17, i32 81, i32 18, i32 82, i32 19, i32 83, i32 20, i32 84, i32 21, i32 85, i32 22, i32 86, i32 23, i32 87, i32 24, i32 88, i32 25, i32 89, i32 26, i32 90, i32 27, i32 91, i32 28, i32 92, i32 29, i32 93, i32 30, i32 94, i32 31, i32 95, i32 32, i32 96, i32 33, i32 97, i32 34, i32 98, i32 35, i32 99, i32 36, i32 100, i32 37, i32 101, i32 38, i32 102, i32 39, i32 103, i32 40, i32 104, i32 41, i32 105, i32 42, i32 106, i32 43, i32 107, i32 44, i32 108, i32 45, i32 109, i32 46, i32 110, i32 47, i32 111, i32 48, i32 112, i32 49, i32 113, i32 50, i32 114, i32 51, i32 115, i32 52, i32 116, i32 53, i32 117, i32 54, i32 118, i32 55, i32 119, i32 56, i32 120, i32 57, i32 121, i32 58, i32 122, i32 59, i32 123, i32 60, i32 124, i32 61, i32 125, i32 62, i32 126, i32 63, i32 127>
|
||||
ret <128 x i8> %p
|
||||
}
|
||||
|
||||
; CHECK-LABEL: test_vshuffh_128:
|
||||
; CHECK: v0.h = vshuff(v0.h)
|
||||
define <128 x i8> @test_vshuffh_128(<128 x i8> %v0) #1 {
|
||||
%p = shufflevector <128 x i8> %v0, <128 x i8> undef, <128 x i32> <i32 0, i32 1, i32 64, i32 65, i32 2, i32 3, i32 66, i32 67, i32 4, i32 5, i32 68, i32 69, i32 6, i32 7, i32 70, i32 71, i32 8, i32 9, i32 72, i32 73, i32 10, i32 11, i32 74, i32 75, i32 12, i32 13, i32 76, i32 77, i32 14, i32 15, i32 78, i32 79, i32 16, i32 17, i32 80, i32 81, i32 18, i32 19, i32 82, i32 83, i32 20, i32 21, i32 84, i32 85, i32 22, i32 23, i32 86, i32 87, i32 24, i32 25, i32 88, i32 89, i32 26, i32 27, i32 90, i32 91, i32 28, i32 29, i32 92, i32 93, i32 30, i32 31, i32 94, i32 95, i32 32, i32 33, i32 96, i32 97, i32 34, i32 35, i32 98, i32 99, i32 36, i32 37, i32 100, i32 101, i32 38, i32 39, i32 102, i32 103, i32 40, i32 41, i32 104, i32 105, i32 42, i32 43, i32 106, i32 107, i32 44, i32 45, i32 108, i32 109, i32 46, i32 47, i32 110, i32 111, i32 48, i32 49, i32 112, i32 113, i32 50, i32 51, i32 114, i32 115, i32 52, i32 53, i32 116, i32 117, i32 54, i32 55, i32 118, i32 119, i32 56, i32 57, i32 120, i32 121, i32 58, i32 59, i32 122, i32 123, i32 60, i32 61, i32 124, i32 125, i32 62, i32 63, i32 126, i32 127>
|
||||
ret <128 x i8> %p
|
||||
}
|
||||
|
||||
attributes #0 = { readnone nounwind "target-cpu"="hexagonv60" "target-features"="+hvx,+hvx-length64b" }
|
||||
attributes #1 = { readnone nounwind "target-cpu"="hexagonv60" "target-features"="+hvx,+hvx-length128b" }
|
||||
|
Loading…
Reference in New Issue