@@ -20382,17 +20382,22 @@ static SDValue LowerTruncateVecI1(SDValue Op, SelectionDAG &DAG,
2038220382 // trying to avoid 512-bit vectors. If we are avoiding 512-bit vectors
2038320383 // we need to split into two 8 element vectors which we can extend to v8i32,
2038420384 // truncate and concat the results. There's an additional complication if
20385- // the original type is v16i8. In that case we can't split the v16i8 so
20386- // first we pre-extend it to v16i16 which we can split to v8i16, then extend
20387- // to v8i32, truncate that to v8i1 and concat the two halves .
20385+ // the original type is v16i8. In that case we can't split the v16i8
20386+ // directly, so we need to shuffle high elements to low and use
20387+ // sign_extend_vector_inreg .
2038820388 if (NumElts == 16 && !Subtarget.canExtendTo512DQ()) {
20389+ SDValue Lo, Hi;
2038920390 if (InVT == MVT::v16i8) {
20390- // First we need to sign extend up to 256-bits so we can split that.
20391- InVT = MVT::v16i16;
20392- In = DAG.getNode(ISD::SIGN_EXTEND, DL, InVT, In);
20391+ Lo = DAG.getNode(ISD::SIGN_EXTEND_VECTOR_INREG, DL, MVT::v8i32, In);
20392+ Hi = DAG.getVectorShuffle(
20393+ InVT, DL, In, In,
20394+ {8, 9, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1});
20395+ Hi = DAG.getNode(ISD::SIGN_EXTEND_VECTOR_INREG, DL, MVT::v8i32, Hi);
20396+ } else {
20397+ assert(InVT == MVT::v16i16 && "Unexpected VT!");
20398+ Lo = extract128BitVector(In, 0, DAG, DL);
20399+ Hi = extract128BitVector(In, 8, DAG, DL);
2039320400 }
20394- SDValue Lo = extract128BitVector(In, 0, DAG, DL);
20395- SDValue Hi = extract128BitVector(In, 8, DAG, DL);
2039620401 // We're split now, just emit two truncates and a concat. The two
2039720402 // truncates will trigger legalization to come back to this function.
2039820403 Lo = DAG.getNode(ISD::TRUNCATE, DL, MVT::v8i1, Lo);
0 commit comments