@@ -2826,32 +2826,32 @@ static bool interp__builtin_ia32_movmsk_op(InterpState &S, CodePtr OpPC,
28262826 unsigned SourceLen = Source.getNumElems ();
28272827 QualType ElemQT = getElemType (Source);
28282828 OptPrimType ElemPT = S.getContext ().classify (ElemQT);
2829- unsigned LaneWidth = S.getASTContext ().getTypeSize (ElemQT);
2829+ unsigned ResultLen =
2830+ S.getASTContext ().getTypeSize (Call->getType ()); // Always 32-bit integer.
2831+ APInt Result (ResultLen, 0 );
28302832
28312833 if (ElemQT->isIntegerType ()) {
2832- unsigned Byte = 8 ;
2833- unsigned ResultLen = (LaneWidth * SourceLen) / Byte;
2834- APInt Result (ResultLen, 0 );
2834+ unsigned BitsInAByte = 8 ;
2835+ unsigned LaneWidth = S.getASTContext ().getTypeSize (ElemQT);
28352836 unsigned ResultIdx = 0 ;
2836- for ( unsigned I = 0 ; I != SourceLen; ++I) {
2837- APInt Lane;
2838- INT_TYPE_SWITCH_NO_BOOL (*ElemPT,
2839- { Lane = Source. elem <T>(I). toAPSInt (); });
2840- for ( unsigned J = 0 ; J != LaneWidth; J += Byte) {
2841- Result. setBitVal (ResultIdx++, Lane[J + 7 ]);
2837+ INT_TYPE_SWITCH_NO_BOOL (*ElemPT, {
2838+ for ( unsigned I = 0 ; I != SourceLen; ++I) {
2839+ APInt Lane = Source. elem <T>(I). toAPSInt ();
2840+ for ( unsigned J = 0 ; J != LaneWidth; J += BitsInAByte) {
2841+ Result. setBitVal (ResultIdx++, Lane[J + 7 ]);
2842+ }
28422843 }
2843- }
2844- pushInteger (S, Result. getZExtValue () , Call->getType ());
2844+ });
2845+ pushInteger (S, Result, Call->getType ());
28452846 return true ;
28462847 }
2847- if (ElemQT->isFloatingType ()) {
2848- APInt Result (SourceLen, 0 );
2848+ if (ElemQT->isRealFloatingType ()) {
28492849 using T = PrimConv<PT_Float>::T;
28502850 for (unsigned I = 0 ; I != SourceLen; ++I) {
28512851 APInt Lane = Source.elem <T>(I).getAPFloat ().bitcastToAPInt ();
2852- Result.setBitVal (I, Lane[LaneWidth - 1 ] );
2852+ Result.setBitVal (I, Lane. isNegative () );
28532853 }
2854- pushInteger (S, Result. getZExtValue () , Call->getType ());
2854+ pushInteger (S, Result, Call->getType ());
28552855 return true ;
28562856 }
28572857 return false ;
0 commit comments