@@ -2824,57 +2824,44 @@ static bool interp__builtin_ia32_test_op(
28242824 const Pointer &LHS = S.Stk .pop <Pointer>();
28252825
28262826 assert (LHS.getNumElems () == RHS.getNumElems ());
2827+
28272828 assert (LHS.getFieldDesc ()->isPrimitiveArray () &&
28282829 RHS.getFieldDesc ()->isPrimitiveArray ());
28292830
28302831 if (!S.getASTContext ().hasSameUnqualifiedType (getElemType (LHS),
28312832 getElemType (RHS)))
28322833 return false ;
28332834
2834- const unsigned SourceLen = LHS.getNumElems ();
2835+ unsigned SourceLen = LHS.getNumElems ();
28352836 const QualType ElemQT = getElemType (LHS);
28362837 const OptPrimType ElemPT = S.getContext ().classify (ElemQT);
2838+ unsigned LaneWidth = S.getASTContext ().getTypeSize (ElemQT);
2839+ APInt SignMask = APInt::getSignMask (LaneWidth);
28372840
2838- if (ElemQT->isIntegerType ()) {
2839- APInt FirstElem;
2840- INT_TYPE_SWITCH_NO_BOOL (*ElemPT,
2841- { FirstElem = LHS.elem <T>(0 ).toAPSInt (); });
2842- const unsigned LaneWidth = FirstElem.getBitWidth ();
2841+ APInt AWide (LaneWidth * SourceLen, 0 );
2842+ APInt BWide (LaneWidth * SourceLen, 0 );
28432843
2844- APInt AWide (LaneWidth * SourceLen, 0 );
2845- APInt BWide (LaneWidth * SourceLen, 0 );
2844+ for (unsigned I = 0 ; I != SourceLen; ++I) {
2845+ APInt ALane;
2846+ APInt BLane;
28462847
2847- for (unsigned I = 0 ; I != SourceLen; ++I) {
2848- APInt ALane;
2849- APInt BLane;
2848+ if (ElemQT->isIntegerType ()) { // Get value
28502849 INT_TYPE_SWITCH_NO_BOOL (*ElemPT, {
28512850 ALane = LHS.elem <T>(I).toAPSInt ();
28522851 BLane = RHS.elem <T>(I).toAPSInt ();
28532852 });
2854- AWide.insertBits (ALane, I * LaneWidth);
2855- BWide.insertBits (BLane, I * LaneWidth);
2856- }
2857- pushInteger (S, Fn (AWide, BWide) ? 1 : 0 , Call->getType ());
2858- return true ;
2859- } else if (ElemQT->isFloatingType ()) {
2860- APInt ASignBits (SourceLen, 0 );
2861- APInt BSignBits (SourceLen, 0 );
2862-
2863- for (unsigned I = 0 ; I != SourceLen; ++I) {
2853+ } else if (ElemQT->isFloatingType ()) { // Get only sign bit
28642854 using T = PrimConv<PT_Float>::T;
2865- APInt ALane = LHS.elem <T>(I).getAPFloat ().bitcastToAPInt ();
2866- APInt BLane = RHS.elem <T>(I).getAPFloat ().bitcastToAPInt ();
2867- const unsigned SignBit = ALane.getBitWidth () - 1 ;
2868- const bool ALaneSign = ALane[SignBit];
2869- const bool BLaneSign = BLane[SignBit];
2870- ASignBits.setBitVal (I, ALaneSign);
2871- BSignBits.setBitVal (I, BLaneSign);
2855+ ALane = LHS.elem <T>(I).getAPFloat ().bitcastToAPInt () & SignMask;
2856+ BLane = RHS.elem <T>(I).getAPFloat ().bitcastToAPInt () & SignMask;
2857+ } else { // Must be integer or floating type
2858+ return false ;
28722859 }
2873- pushInteger (S, Fn (ASignBits, BSignBits) ? 1 : 0 , Call->getType ());
2874- return true ;
2875- } else { // Must be integer or float type
2876- return false ;
2860+ AWide.insertBits (ALane, I * LaneWidth);
2861+ BWide.insertBits (BLane, I * LaneWidth);
28772862 }
2863+ pushInteger (S, Fn (AWide, BWide), Call->getType ());
2864+ return true ;
28782865}
28792866
28802867static bool interp__builtin_elementwise_triop (
0 commit comments