Skip to content

Commit 6228ba6

Browse files
committed
[Headers][X86] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - allow PALIGNR byte shift intrinsics to be used in constexpr
1 parent 3149a77 commit 6228ba6

File tree

8 files changed

+255
-4
lines changed

8 files changed

+255
-4
lines changed

clang/include/clang/Basic/BuiltinsX86.td

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ let Features = "sse2", Attributes = [NoThrow, Const, RequiredVectorWidth<128>] i
280280
def psllq128 : X86Builtin<"_Vector<2, long long int>(_Vector<2, long long int>, _Vector<2, long long int>)">;
281281
def pmaddwd128 : X86Builtin<"_Vector<4, int>(_Vector<8, short>, _Vector<8, short>)">;
282282
def pslldqi128_byteshift : X86Builtin<"_Vector<16, char>(_Vector<16, char>, _Constant int)">;
283-
def psrldqi128_byteshift : X86Builtin<"_Vector<16, char>(_Vector<16, char>, _Constant int)">;
283+
284284
}
285285

286286
let Features = "sse2",
@@ -297,6 +297,8 @@ let Features = "sse2",
297297

298298
def psrawi128 : X86Builtin<"_Vector<8, short>(_Vector<8, short>, int)">;
299299
def psradi128 : X86Builtin<"_Vector<4, int>(_Vector<4, int>, int)">;
300+
301+
def psrldqi128_byteshift : X86Builtin<"_Vector<16, char>(_Vector<16, char>, _Constant int)">;
300302
}
301303

302304
let Features = "sse3", Attributes = [NoThrow] in {
@@ -308,7 +310,7 @@ let Features = "sse3", Attributes = [NoThrow, RequiredVectorWidth<128>] in {
308310
def lddqu : X86Builtin<"_Vector<16, char>(char const *)">;
309311
}
310312

311-
let Features = "ssse3", Attributes = [NoThrow, Const, RequiredVectorWidth<128>] in {
313+
let Features = "ssse3", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in {
312314
def palignr128 : X86Builtin<"_Vector<16, char>(_Vector<16, char>, _Vector<16, char>, _Constant int)">;
313315
}
314316

@@ -574,7 +576,6 @@ let Features = "avx", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWid
574576

575577
let Features = "avx2", Attributes = [NoThrow, Const, RequiredVectorWidth<256>] in {
576578
def mpsadbw256 : X86Builtin<"_Vector<32, char>(_Vector<32, char>, _Vector<32, char>, _Constant char)">;
577-
def palignr256 : X86Builtin<"_Vector<32, char>(_Vector<32, char>, _Vector<32, char>, _Constant int)">;
578579
def phaddw256 : X86Builtin<"_Vector<16, short>(_Vector<16, short>, _Vector<16, short>)">;
579580
def phaddd256 : X86Builtin<"_Vector<8, int>(_Vector<8, int>, _Vector<8, int>)">;
580581
def phaddsw256 : X86Builtin<"_Vector<16, short>(_Vector<16, short>, _Vector<16, short>)">;
@@ -610,6 +611,7 @@ let Features = "avx2", Attributes = [NoThrow, Const, RequiredVectorWidth<256>] i
610611

611612

612613
let Features = "avx2", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<256>] in {
614+
def palignr256 : X86Builtin<"_Vector<32, char>(_Vector<32, char>, _Vector<32, char>, _Constant int)">;
613615
def pavgb256 : X86Builtin<"_Vector<32, unsigned char>(_Vector<32, unsigned char>, _Vector<32, unsigned char>)">;
614616
def pavgw256 : X86Builtin<"_Vector<16, unsigned short>(_Vector<16, unsigned short>, _Vector<16, unsigned short>)">;
615617

@@ -3232,7 +3234,7 @@ let Features = "avx512bw", Attributes = [NoThrow, Const] in {
32323234
def kmovq : X86Builtin<"unsigned long long int(unsigned long long int)">;
32333235
}
32343236

3235-
let Features = "avx512bw", Attributes = [NoThrow, Const, RequiredVectorWidth<512>] in {
3237+
let Features = "avx512bw", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<512>] in {
32363238
def palignr512 : X86Builtin<"_Vector<64, char>(_Vector<64, char>, _Vector<64, char>, _Constant int)">;
32373239
}
32383240

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2975,6 +2975,73 @@ static bool interp__builtin_vec_set(InterpState &S, CodePtr OpPC,
29752975
return true;
29762976
}
29772977

2978+
static bool interp__builtin_x86_psrldq_byteshift(InterpState &S, CodePtr OpPC, const CallExpr *Call, unsigned ID) {
2979+
assert(Call->getNumArgs() == 2);
2980+
2981+
APSInt ImmAPS = popToAPSInt(S, Call->getArg(1));
2982+
uint64_t Shift = ImmAPS.getZExtValue();
2983+
2984+
const Pointer &Concat = S.Stk.pop<Pointer>();
2985+
if (!Concat.getFieldDesc()->isPrimitiveArray())
2986+
return false;
2987+
2988+
unsigned NumElems = Concat.getNumElems();
2989+
const Pointer &Dst = S.Stk.peek<Pointer>();
2990+
PrimType ElemPT = Concat.getFieldDesc()->getPrimType();
2991+
2992+
TYPE_SWITCH(ElemPT, {
2993+
for (unsigned I = 0; I < NumElems; ++I) {
2994+
if (I + Shift < NumElems)
2995+
Dst.elem<T>(I) = Concat.elem<T>(I + Shift);
2996+
else
2997+
Dst.elem<T>(I) = T();
2998+
}
2999+
});
3000+
3001+
Dst.initializeAllElements();
3002+
3003+
return true;
3004+
}
3005+
3006+
static bool interp__builtin_x86_palignr(InterpState &S, CodePtr OpPC,
3007+
const CallExpr *Call, unsigned ID) {
3008+
3009+
APSInt ImmAPS = popToAPSInt(S, Call->getArg(2));
3010+
uint64_t Shift = ImmAPS.getZExtValue();
3011+
3012+
const Pointer &VecB = S.Stk.pop<Pointer>();
3013+
if (!VecB.getFieldDesc()->isPrimitiveArray())
3014+
return false;
3015+
3016+
const Pointer &VecA = S.Stk.pop<Pointer>();
3017+
if (!VecA.getFieldDesc()->isPrimitiveArray())
3018+
return false;
3019+
3020+
const Pointer &Dst = S.Stk.peek<Pointer>();
3021+
PrimType ElemPT = VecA.getFieldDesc()->getPrimType();
3022+
3023+
unsigned LenA = VecA.getNumElems();
3024+
unsigned LenB = VecB.getNumElems();
3025+
3026+
assert(LenA == LenB && (LenA %16 == 0));
3027+
3028+
TYPE_SWITCH(ElemPT, {
3029+
for (unsigned I = 0; I < LenA; ++I) {
3030+
if (I + Shift < LenA) {
3031+
Dst.elem<T>(I) = VecB.elem<T>(I + Shift);
3032+
}else if (I + Shift < LenA + LenB) {
3033+
Dst.elem<T>(I) = VecA.elem<T>(I + Shift -LenA);
3034+
}
3035+
else {
3036+
Dst.elem<T>(I) = T();
3037+
}
3038+
}
3039+
});
3040+
3041+
Dst.initializeAllElements();
3042+
return true;
3043+
}
3044+
29783045
bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
29793046
uint32_t BuiltinID) {
29803047
if (!S.getASTContext().BuiltinInfo.isConstantEvaluated(BuiltinID))
@@ -3821,6 +3888,14 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
38213888
case X86::BI__builtin_ia32_vec_set_v4di:
38223889
return interp__builtin_vec_set(S, OpPC, Call, BuiltinID);
38233890

3891+
case X86::BI__builtin_ia32_psrldqi128_byteshift:
3892+
return interp__builtin_x86_psrldq_byteshift(S, OpPC, Call, BuiltinID);
3893+
3894+
case X86::BI__builtin_ia32_palignr128:
3895+
case X86::BI__builtin_ia32_palignr256:
3896+
case X86::BI__builtin_ia32_palignr512:
3897+
return interp__builtin_x86_palignr(S, OpPC, Call, BuiltinID);
3898+
38243899
default:
38253900
S.FFDiag(S.Current->getLocation(OpPC),
38263901
diag::note_invalid_subexpr_in_const_expr)

clang/lib/AST/ExprConstant.cpp

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12350,6 +12350,68 @@ bool VectorExprEvaluator::VisitCallExpr(const CallExpr *E) {
1235012350
Elems.push_back(ElemNum == Index ? ElemAV : VecVal.getVectorElt(ElemNum));
1235112351

1235212352
return Success(APValue(Elems.data(), NumElems), E);
12353+
12354+
case X86::BI__builtin_ia32_psrldqi128_byteshift: {
12355+
assert(E->getNumArgs() == 2);
12356+
12357+
APValue Concat;
12358+
APSInt Imm;
12359+
if (!EvaluateAsRValue(Info, E->getArg(0), Concat) ||
12360+
!EvaluateInteger(E->getArg(1), Imm, Info))
12361+
return false;
12362+
12363+
unsigned VecLen = Concat.getVectorLength();
12364+
unsigned Shift = Imm.getZExtValue();
12365+
12366+
SmallVector<APValue> ResultElements;
12367+
for (unsigned I = 0; I < VecLen; ++I) {
12368+
if (I + Shift < VecLen) {
12369+
ResultElements.push_back(Concat.getVectorElt(I + Shift));
12370+
} else {
12371+
APSInt Zero(8, /*isUnsigned=*/true);
12372+
Zero = 0;
12373+
ResultElements.push_back(APValue(Zero));
12374+
}
12375+
}
12376+
12377+
return Success(APValue(ResultElements.data(), ResultElements.size()), E);
12378+
}
12379+
12380+
case X86::BI__builtin_ia32_palignr128:
12381+
case X86::BI__builtin_ia32_palignr256:
12382+
case X86::BI__builtin_ia32_palignr512: {
12383+
assert(E->getNumArgs() == 3);
12384+
12385+
APValue VecA, VecB;
12386+
APSInt Imm;
12387+
if (!EvaluateAsRValue(Info, E->getArg(0), VecA) ||
12388+
!EvaluateAsRValue(Info, E->getArg(1), VecB) ||
12389+
!EvaluateInteger(E->getArg(2), Imm, Info))
12390+
return false;
12391+
12392+
12393+
if (!VecA.isVector() || !VecB.isVector())
12394+
return false;
12395+
12396+
unsigned LenA = VecA.getVectorLength();
12397+
unsigned LenB = VecB.getVectorLength();
12398+
assert(LenA == LenB && (LenA % 16 == 0));
12399+
12400+
unsigned Shift = Imm.getZExtValue();
12401+
SmallVector<APValue> ResultElements;
12402+
for (unsigned I = 0; I < LenA; ++I) {
12403+
if (I + Shift < LenA) {
12404+
ResultElements.push_back(VecB.getVectorElt(I + Shift));
12405+
}else if (I + Shift < LenA + LenB) {
12406+
ResultElements.push_back(VecA.getVectorElt(I + Shift - LenA));
12407+
}else {
12408+
APSInt Zero(/*BitWidth=*/8, /*isUnsigned=*/true);
12409+
Zero = 0;
12410+
ResultElements.push_back(APValue(Zero));
12411+
}
12412+
}
12413+
12414+
return Success(APValue(ResultElements.data(), ResultElements.size()), E);
1235312415
}
1235412416
}
1235512417
}

clang/test/CodeGen/X86/avx2-builtins.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,22 @@ __m256i test_mm256_alignr_epi8(__m256i a, __m256i b) {
109109
// CHECK: shufflevector <32 x i8> %{{.*}}, <32 x i8> %{{.*}}, <32 x i32> <i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 32, i32 33, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31, i32 48, i32 49>
110110
return _mm256_alignr_epi8(a, b, 2);
111111
}
112+
TEST_CONSTEXPR(
113+
match_v32qi(
114+
_mm256_alignr_epi8((
115+
(__m256i)(__v32qs){1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32}),
116+
((__m256i)(__v32qs){33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64}), 2),
117+
35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 1, 2
118+
)
119+
);
120+
TEST_CONSTEXPR(
121+
match_v32qi(
122+
_mm256_alignr_epi8((
123+
(__m256i)(__v32qs){1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32}),
124+
((__m256i)(__v32qs){33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64}), 64),
125+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
126+
)
127+
);
112128

113129
__m256i test2_mm256_alignr_epi8(__m256i a, __m256i b) {
114130
// CHECK-LABEL: test2_mm256_alignr_epi8

clang/test/CodeGen/X86/avx512bw-builtins.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2661,20 +2661,53 @@ __m512i test_mm512_alignr_epi8(__m512i __A,__m512i __B){
26612661
// CHECK: shufflevector <64 x i8> %{{.*}}, <64 x i8> %{{.*}}, <64 x i32> <i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 64, i32 65, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31, i32 80, i32 81, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 96, i32 97, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 58, i32 59, i32 60, i32 61, i32 62, i32 63, i32 112, i32 113>
26622662
return _mm512_alignr_epi8(__A, __B, 2);
26632663
}
2664+
TEST_CONSTEXPR(
2665+
match_v64qi(
2666+
_mm512_alignr_epi8(
2667+
((__m512i)(__v64qs){1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64}),
2668+
((__m512i)(__v64qs){65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 127}),
2669+
2), 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 127, 1, 2
2670+
)
2671+
);
2672+
TEST_CONSTEXPR(
2673+
match_v64qi(
2674+
_mm512_alignr_epi8(
2675+
((__m512i)(__v64qs){1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64}),
2676+
((__m512i)(__v64qs){65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 127}),
2677+
128), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
2678+
)
2679+
);
2680+
26642681

26652682
__m512i test_mm512_mask_alignr_epi8(__m512i __W, __mmask64 __U, __m512i __A,__m512i __B){
26662683
// CHECK-LABEL: test_mm512_mask_alignr_epi8
26672684
// CHECK: shufflevector <64 x i8> %{{.*}}, <64 x i8> %{{.*}}, <64 x i32> <i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 64, i32 65, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31, i32 80, i32 81, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 96, i32 97, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 58, i32 59, i32 60, i32 61, i32 62, i32 63, i32 112, i32 113>
26682685
// CHECK: select <64 x i1> %{{.*}}, <64 x i8> %{{.*}}, <64 x i8> %{{.*}}
26692686
return _mm512_mask_alignr_epi8(__W, __U, __A, __B, 2);
26702687
}
2688+
TEST_CONSTEXPR(
2689+
match_v64qi(
2690+
_mm512_mask_alignr_epi8(((__m512i)(__v64qs){127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127}), (__mmask64)0x000000000000000f,
2691+
((__m512i)(__v64qs){1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64}),
2692+
((__m512i)(__v64qs){65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 127}),
2693+
2), 67, 68, 69, 70, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127
2694+
)
2695+
);
26712696

26722697
__m512i test_mm512_maskz_alignr_epi8(__mmask64 __U, __m512i __A,__m512i __B){
26732698
// CHECK-LABEL: test_mm512_maskz_alignr_epi8
26742699
// CHECK: shufflevector <64 x i8> %{{.*}}, <64 x i8> %{{.*}}, <64 x i32> <i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 64, i32 65, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31, i32 80, i32 81, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 96, i32 97, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 58, i32 59, i32 60, i32 61, i32 62, i32 63, i32 112, i32 113>
26752700
// CHECK: select <64 x i1> %{{.*}}, <64 x i8> %{{.*}}, <64 x i8> %{{.*}}
26762701
return _mm512_maskz_alignr_epi8(__U, __A, __B, 2);
26772702
}
2703+
TEST_CONSTEXPR(
2704+
match_v64qi(
2705+
_mm512_maskz_alignr_epi8((__mmask64)0x000000000000000f,
2706+
((__m512i)(__v64qs){1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64}),
2707+
((__m512i)(__v64qs){65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 127}),
2708+
2), 67, 68, 69, 70, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
2709+
)
2710+
);
26782711

26792712

26802713

clang/test/CodeGen/X86/avx512vlbw-builtins.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3313,27 +3313,61 @@ __m128i test_mm_mask_alignr_epi8(__m128i __W, __mmask16 __U, __m128i __A, __m128
33133313
// CHECK: select <16 x i1> %{{.*}}, <16 x i8> %{{.*}}, <16 x i8> %{{.*}}
33143314
return _mm_mask_alignr_epi8(__W, __U, __A, __B, 2);
33153315
}
3316+
TEST_CONSTEXPR(
3317+
match_v16qi(
3318+
_mm_mask_alignr_epi8(((__m128i)(__v16qs){127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127}), (__mmask16)0x000f,
3319+
((__m128i)(__v16qs){1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}),
3320+
((__m128i)(__v16qs){17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32}), 2),
3321+
19, 20, 21, 22, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127
3322+
)
3323+
);
33163324

33173325
__m128i test_mm_maskz_alignr_epi8(__mmask16 __U, __m128i __A, __m128i __B) {
33183326
// CHECK-LABEL: test_mm_maskz_alignr_epi8
33193327
// CHECK: shufflevector <16 x i8> %{{.*}}, <16 x i8> %{{.*}}, <16 x i32> <i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17>
33203328
// CHECK: select <16 x i1> %{{.*}}, <16 x i8> %{{.*}}, <16 x i8> %{{.*}}
33213329
return _mm_maskz_alignr_epi8(__U, __A, __B, 2);
33223330
}
3331+
TEST_CONSTEXPR(
3332+
match_v16qi(
3333+
_mm_maskz_alignr_epi8((__mmask16)0x000f,
3334+
((__m128i)(__v16qs){1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}),
3335+
((__m128i)(__v16qs){17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32}),
3336+
2), 19, 20, 21, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
3337+
)
3338+
);
3339+
33233340

33243341
__m256i test_mm256_mask_alignr_epi8(__m256i __W, __mmask32 __U, __m256i __A, __m256i __B) {
33253342
// CHECK-LABEL: test_mm256_mask_alignr_epi8
33263343
// CHECK: shufflevector <32 x i8> %{{.*}}, <32 x i8> %{{.*}}, <32 x i32> <i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 32, i32 33, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31, i32 48, i32 49>
33273344
// CHECK: select <32 x i1> %{{.*}}, <32 x i8> %{{.*}}, <32 x i8> %{{.*}}
33283345
return _mm256_mask_alignr_epi8(__W, __U, __A, __B, 2);
33293346
}
3347+
TEST_CONSTEXPR(
3348+
match_v32qi(
3349+
_mm256_mask_alignr_epi8(((__m256i)(__v32qs){127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127}), (__mmask32)0x0000000f,
3350+
((__m256i)(__v32qs){1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32}),
3351+
((__m256i)(__v32qs){33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64}),
3352+
2), 35, 36, 37, 38, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127
3353+
)
3354+
);
3355+
33303356

33313357
__m256i test_mm256_maskz_alignr_epi8(__mmask32 __U, __m256i __A, __m256i __B) {
33323358
// CHECK-LABEL: test_mm256_maskz_alignr_epi8
33333359
// CHECK: shufflevector <32 x i8> %{{.*}}, <32 x i8> %{{.*}}, <32 x i32> <i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 32, i32 33, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31, i32 48, i32 49>
33343360
// CHECK: select <32 x i1> %{{.*}}, <32 x i8> %{{.*}}, <32 x i8> %{{.*}}
33353361
return _mm256_maskz_alignr_epi8(__U, __A, __B, 2);
33363362
}
3363+
TEST_CONSTEXPR(
3364+
match_v32qi(
3365+
_mm256_maskz_alignr_epi8((__mmask32)0x0000000f,
3366+
((__m256i)(__v32qs){1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32}),
3367+
((__m256i)(__v32qs){33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64}),
3368+
2), 35, 36, 37, 38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
3369+
)
3370+
);
33373371

33383372
__m128i test_mm_dbsad_epu8(__m128i __A, __m128i __B) {
33393373
// CHECK-LABEL: test_mm_dbsad_epu8

0 commit comments

Comments
 (0)