================
@@ -3531,6 +3531,64 @@ static bool
interp__builtin_ia32_shufbitqmb_mask(InterpState &S, CodePtr OpPC,
return true;
}
+static bool interp__builtin_ia32_multishiftqb(InterpState &S, CodePtr OpPC,
+ const CallExpr *Call) {
+ assert(Call->getNumArgs() == 2);
+
+ QualType ATy = Call->getArg(0)->getType();
+ QualType BTy = Call->getArg(1)->getType();
+ if (!ATy->isVectorType() || !BTy->isVectorType()) {
+ return false;
+ }
+
+ const Pointer &BPtr = S.Stk.pop<Pointer>();
+ const Pointer &APtr = S.Stk.pop<Pointer>();
+ const auto *AVecT = ATy->castAs<VectorType>();
+ assert(AVecT->getNumElements() ==
+ BTy->castAs<VectorType>()->getNumElements());
+
+ PrimType ElemT = *S.getContext().classify(AVecT->getElementType());
+
+ unsigned NumBytesInQWord = 8;
+ unsigned NumBitsInByte = 8;
+ unsigned NumBytes = AVecT->getNumElements();
+ unsigned NumQWords = NumBytes / NumBytesInQWord;
+ const Pointer &Dst = S.Stk.peek<Pointer>();
+
+ for (unsigned QWordId = 0; QWordId != NumQWords; ++QWordId) {
+ APInt BQWord(64, 0);
+ for (unsigned ByteIdx = 0; ByteIdx != NumBytesInQWord; ++ByteIdx) {
+ unsigned Idx = QWordId * NumBytesInQWord + ByteIdx;
+ INT_TYPE_SWITCH(ElemT, {
+ uint64_t Byte = static_cast<uint64_t>(BPtr.elem<T>(Idx));
+ BQWord.insertBits(APInt(8, Byte & 0xFF), ByteIdx * NumBitsInByte);
+ });
+ }
+
+ for (unsigned ByteIdx = 0; ByteIdx != NumBytesInQWord; ++ByteIdx) {
+ uint64_t Ctrl = 0;
+ INT_TYPE_SWITCH(ElemT, {
+ Ctrl = static_cast<uint64_t>(
+ APtr.elem<T>(QWordId * NumBytesInQWord + ByteIdx)) &
+ 0x3F;
+ });
+
+ APInt Byte(8, 0);
+ for (unsigned BitIdx = 0; BitIdx != NumBitsInByte; ++BitIdx) {
+ Byte.setBitVal(BitIdx, BQWord[(Ctrl + BitIdx) & 0x3F]);
+ }
+ INT_TYPE_SWITCH(ElemT, {
+ Dst.elem<T>(QWordId * NumBytesInQWord + ByteIdx) =
----------------
RKSimon wrote:
hoist this `unsigned Idx = QWordId * NumBytesInQWord + ByteIdx;` - we now
repeat it.
https://github.com/llvm/llvm-project/pull/168995
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits