@@ -20382,17 +20382,22 @@ static SDValue LowerTruncateVecI1(SDValue Op, SelectionDAG &DAG,
20382
20382
// trying to avoid 512-bit vectors. If we are avoiding 512-bit vectors
20383
20383
// we need to split into two 8 element vectors which we can extend to v8i32,
20384
20384
// 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 .
20388
20388
if (NumElts == 16 && !Subtarget.canExtendTo512DQ()) {
20389
+ SDValue Lo, Hi;
20389
20390
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);
20393
20400
}
20394
- SDValue Lo = extract128BitVector(In, 0, DAG, DL);
20395
- SDValue Hi = extract128BitVector(In, 8, DAG, DL);
20396
20401
// We're split now, just emit two truncates and a concat. The two
20397
20402
// truncates will trigger legalization to come back to this function.
20398
20403
Lo = DAG.getNode(ISD::TRUNCATE, DL, MVT::v8i1, Lo);
0 commit comments