@@ -13766,40 +13766,6 @@ static bool getBuiltinAlignArguments(const CallExpr *E, EvalInfo &Info,
1376613766
1376713767bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
1376813768 unsigned BuiltinOp) {
13769-
13770- auto EvalMoveMaskOp = [&]() {
13771- APValue Source;
13772- if (!Evaluate(Source, Info, E->getArg(0)))
13773- return false;
13774- unsigned SourceLen = Source.getVectorLength();
13775- const VectorType *VT = E->getArg(0)->getType()->castAs<VectorType>();
13776- const QualType ElemQT = VT->getElementType();
13777- unsigned LaneWidth = Info.Ctx.getTypeSize(ElemQT);
13778-
13779- if (ElemQT->isIntegerType()) { // Get MSB of each byte of every lane
13780- unsigned ByteLen = 8;
13781- unsigned ResultLen = (LaneWidth * SourceLen) / ByteLen;
13782- APInt Result(ResultLen, 0);
13783- unsigned ResultIdx = 0;
13784- for (unsigned I = 0; I != SourceLen; ++I) {
13785- APInt Lane = Source.getVectorElt(I).getInt();
13786- for (unsigned J = 0; J != LaneWidth; J = J + ByteLen) {
13787- Result.setBitVal(ResultIdx++, Lane[J]);
13788- }
13789- }
13790- return Success(Result, E);
13791- }
13792- if (ElemQT->isFloatingType()) { // Get sign bit of every lane
13793- APInt Result(SourceLen, 0);
13794- for (unsigned I = 0; I != SourceLen; ++I) {
13795- APInt Lane = Source.getVectorElt(I).getFloat().bitcastToAPInt();
13796- Result.setBitVal(I, Lane[LaneWidth - 1]);
13797- }
13798- return Success(Result, E);
13799- }
13800- return false;
13801- };
13802-
1380313769 auto HandleMaskBinOp =
1380413770 [&](llvm::function_ref<APSInt(const APSInt &, const APSInt &)> Fn)
1380513771 -> bool {
@@ -14834,7 +14800,36 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
1483414800 case clang::X86::BI__builtin_ia32_pmovmskb256:
1483514801 case clang::X86::BI__builtin_ia32_movmskps256:
1483614802 case clang::X86::BI__builtin_ia32_movmskpd256: {
14837- return EvalMoveMaskOp();
14803+ APValue Source;
14804+ if (!Evaluate(Source, Info, E->getArg(0)))
14805+ return false;
14806+ unsigned SourceLen = Source.getVectorLength();
14807+ const VectorType *VT = E->getArg(0)->getType()->castAs<VectorType>();
14808+ const QualType ElemQT = VT->getElementType();
14809+ unsigned LaneWidth = Info.Ctx.getTypeSize(ElemQT);
14810+
14811+ if (ElemQT->isIntegerType()) { // Get MSB of each byte of every lane
14812+ unsigned Byte = 8;
14813+ unsigned ResultLen = (LaneWidth * SourceLen) / Byte;
14814+ APInt Result(ResultLen, 0);
14815+ unsigned ResultIdx = 0;
14816+ for (unsigned I = 0; I != SourceLen; ++I) {
14817+ APInt Lane = Source.getVectorElt(I).getInt();
14818+ for (unsigned J = 0; J != LaneWidth; J += Byte) {
14819+ Result.setBitVal(ResultIdx++, Lane[J + 7]);
14820+ }
14821+ }
14822+ return Success(Result.getZExtValue(), E);
14823+ }
14824+ if (ElemQT->isFloatingType()) { // Get sign bit of every lane
14825+ APInt Result(SourceLen, 0);
14826+ for (unsigned I = 0; I != SourceLen; ++I) {
14827+ APInt Lane = Source.getVectorElt(I).getFloat().bitcastToAPInt();
14828+ Result.setBitVal(I, Lane[LaneWidth - 1]);
14829+ }
14830+ return Success(Result.getZExtValue(), E);
14831+ }
14832+ return false;
1483814833 }
1483914834
1484014835 case clang::X86::BI__builtin_ia32_bextr_u32:
0 commit comments