================ @@ -2604,6 +2604,68 @@ static bool interp__builtin_elementwise_int_binop( return true; } +static bool interp__builtin_x86_pack( + InterpState &S, CodePtr, const CallExpr *E, unsigned SrcBits, bool IsUnsat, + llvm::function_ref<APSInt(const APSInt &X, unsigned, unsigned, bool)> + narrowElement) { + const auto *VT0 = E->getArg(0)->getType()->castAs<VectorType>(); + const auto *VT1 = E->getArg(1)->getType()->castAs<VectorType>(); + assert(VT0 && VT1 && "pack builtin VT0 and VT1 must be VectorType"); + assert(VT0->getElementType() == VT1->getElementType() && + VT0->getNumElements() == VT1->getNumElements() && + "pack builtin VT0 and VT1 ElementType must be same"); + + const unsigned LHSVecLen = VT0->getNumElements(); + + const Pointer &RHS = S.Stk.pop<Pointer>(); + const Pointer &LHS = S.Stk.pop<Pointer>(); + const Pointer &Dst = S.Stk.peek<Pointer>(); + + auto readSrc = [&](const Pointer &P, unsigned I) -> APSInt { + if (SrcBits == 16) { + int16_t v = P.elem<int16_t>(I); + return APSInt(APInt(16, static_cast<uint16_t>(v)), /*isUnsigned=*/false); + } else { + int32_t v = P.elem<int32_t>(I); + return APSInt(APInt(32, static_cast<uint32_t>(v)), /*isUnsigned=*/false); + } + }; + + const unsigned DstBits = SrcBits / 2; + auto writeDst = [&](unsigned I, const APSInt &Y) { + if (DstBits == 8) { ---------------- woruyu wrote:
Done! replace it wiith `APSInt Tmp + setIsUnsigned + extOrTrunc + assignInteger` https://github.com/llvm/llvm-project/pull/156003 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits