@@ -12025,8 +12025,58 @@ bool VectorExprEvaluator::VisitCallExpr(const CallExpr *E) {
1202512025
1202612026 return Success(APValue(ResultElements.data(), ResultElements.size()), E);
1202712027 }
12028- case X86::BI__builtin_ia32_ptestz128:
12029- case X86::BI__builtin_ia32_ptestz256:
12028+ case X86::BI__builtin_ia32_ptestz128: {
12029+ APValue SourceLHS, SourceRHS;
12030+ if (!EvaluateAsRValue(Info, E->getArg(0), SourceLHS) ||
12031+ !EvaluateAsRValue(Info, E->getArg(1), SourceRHS))
12032+ return false;
12033+
12034+ unsigned SourceLen = SourceLHS.getVectorLength();
12035+ bool Flag = true;
12036+ for (unsigned I = 0; I < SourceLen; ++I) {
12037+ const APInt &A = SourceLHS.getVectorElt(I).getInt();
12038+ const APInt &B = SourceRHS.getVectorElt(I).getInt();
12039+ if ((A & B) != 0) {
12040+ Flag = false;
12041+ break;
12042+ }
12043+ }
12044+
12045+ QualType ResultType = E->getType();
12046+ unsigned BitWidth = Info.Ctx.getIntWidth(ResultType);
12047+ bool ResultSigned = ResultType->isUnsignedIntegerOrEnumerationType();
12048+ APSInt Result(APInt(BitWidth, Flag), ResultSigned);
12049+ return Success(APValue(Result), E);
12050+
12051+ // auto *DestTy = E->getType()->castAs<VectorType>();
12052+ // QualType DestEltTy = DestTy->getElementType();
12053+ // bool DestUnsigned = DestEltTy->isUnsignedIntegerOrEnumerationType();
12054+ // const unsigned SourceLen = SourceLHS.getVectorLength();
12055+ // SmallVector<APValue, 4> ResultElements;
12056+ // ResultElements.reserve(SourceLen);
12057+
12058+ // unsigned BitWidth = SourceLHS.getVectorElt(0).getInt().getBitWidth();
12059+
12060+ // auto PopulateResultElements = [&](bool Flag) {
12061+ // for (unsigned I = 0; I < SourceLen - 1; ++I) {
12062+ // ResultElements.emplace_back(APSInt(APInt::getZero(BitWidth), DestUnsigned));
12063+ // }
12064+ // ResultElements.emplace_back(APSInt(APInt(BitWidth, Flag), DestUnsigned));
12065+ // };
12066+
12067+ // for (unsigned EltNum = 0; EltNum < SourceLen; ++EltNum) {
12068+ // const APInt &A = SourceLHS.getVectorElt(EltNum).getInt();
12069+ // const APInt &B = SourceRHS.getVectorElt(EltNum).getInt();
12070+ // if ((A & B) != 0) {
12071+ // PopulateResultElements(false);
12072+ // return Success(APValue(ResultElements.data(), SourceLen), E);
12073+ // }
12074+ // }
12075+ // PopulateResultElements(true);
12076+ // return Success(APValue(ResultElements.data(), SourceLen), E);
12077+ }
12078+
12079+ // case clang::X86::BI__builtin_ia32_ptestz256:
1203012080
1203112081 // case X86::BI__builtin_ia32_ptestc128:
1203212082 // case X86::BI__builtin_ia32_ptestc256:
0 commit comments