@@ -3101,6 +3101,33 @@ static bool interp__builtin_vec_set(InterpState &S, CodePtr OpPC,
31013101 return true ;
31023102}
31033103
3104+ static bool interp__builtin_ia32_vpconflict (InterpState &S, CodePtr OpPC,
3105+ const CallExpr *Call) {
3106+ assert (Call->getNumArgs () == 1 );
3107+
3108+ QualType Arg0Type = Call->getArg (0 )->getType ();
3109+ const auto *VecT = Arg0Type->castAs <VectorType>();
3110+ PrimType ElemT = *S.getContext ().classify (VecT->getElementType ());
3111+ unsigned NumElems = VecT->getNumElements ();
3112+ bool DestUnsigned = Call->getType ()->isUnsignedIntegerOrEnumerationType ();
3113+ const Pointer &Src = S.Stk .pop <Pointer>();
3114+ const Pointer &Dst = S.Stk .peek <Pointer>();
3115+
3116+ for (unsigned I = 0 ; I != NumElems; ++I) {
3117+ INT_TYPE_SWITCH_NO_BOOL (ElemT, {
3118+ APSInt ElemI = Src.elem <T>(I).toAPSInt ();
3119+ APInt ConflictMask (ElemI.getBitWidth (), 0 );
3120+ for (unsigned J = 0 ; J != I; ++J) {
3121+ APSInt ElemJ = Src.elem <T>(J).toAPSInt ();
3122+ ConflictMask.setBitVal (J, ElemI == ElemJ);
3123+ }
3124+ Dst.elem <T>(I) = static_cast <T>(APSInt (ConflictMask, DestUnsigned));
3125+ });
3126+ }
3127+ Dst.initializeAllElements ();
3128+ return true ;
3129+ }
3130+
31043131bool InterpretBuiltin (InterpState &S, CodePtr OpPC, const CallExpr *Call,
31053132 uint32_t BuiltinID) {
31063133 if (!S.getASTContext ().BuiltinInfo .isConstantEvaluated (BuiltinID))
@@ -3891,7 +3918,13 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
38913918 [](const APSInt &Lo, const APSInt &Hi, const APSInt &Amt) {
38923919 return llvm::APIntOps::fshr (Hi, Lo, Amt);
38933920 });
3894-
3921+ case X86::BI__builtin_ia32_vpconflictsi_128:
3922+ case X86::BI__builtin_ia32_vpconflictsi_256:
3923+ case X86::BI__builtin_ia32_vpconflictsi_512:
3924+ case X86::BI__builtin_ia32_vpconflictdi_128:
3925+ case X86::BI__builtin_ia32_vpconflictdi_256:
3926+ case X86::BI__builtin_ia32_vpconflictdi_512:
3927+ return interp__builtin_ia32_vpconflict (S, OpPC, Call);
38953928 case clang::X86::BI__builtin_ia32_blendpd:
38963929 case clang::X86::BI__builtin_ia32_blendpd256:
38973930 case clang::X86::BI__builtin_ia32_blendps:
0 commit comments