Index: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp =================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp @@ -18652,7 +18652,7 @@ MVT WideEltVT = WideVT.getVectorElementType(); if ((Subtarget.hasDQI() && WideEltVT.getSizeInBits() >= 32) || (Subtarget.hasBWI() && WideEltVT.getSizeInBits() <= 16)) { - V = getExtendInVec(X86ISD::VSEXT, dl, WideVT, In, DAG); + V = DAG.getNode(ISD::SIGN_EXTEND, dl, WideVT, In); } else { SDValue NegOne = getOnesVector(WideVT, DAG, dl); SDValue Zero = getZeroVector(WideVT, Subtarget, DAG, dl); @@ -25763,7 +25763,15 @@ return false; } -bool X86TargetLowering::isVectorLoadExtDesirable(SDValue) const { return true; } +bool X86TargetLowering::isVectorLoadExtDesirable(SDValue ExtVal) const { + EVT SrcVT = ExtVal.getOperand(0).getValueType(); + + // There is no extending load for vXi1. + if (SrcVT.getScalarType() == MVT::i1) + return false; + + return true; +} bool X86TargetLowering::isFMAFasterThanFMulAndFAdd(EVT VT) const { Index: llvm/trunk/lib/Target/X86/X86InstrAVX512.td =================================================================== --- llvm/trunk/lib/Target/X86/X86InstrAVX512.td +++ llvm/trunk/lib/Target/X86/X86InstrAVX512.td @@ -8740,7 +8740,7 @@ multiclass cvt_by_vec_width opc, X86VectorVTInfo Vec, string OpcodeStr > { def rr : AVX512XS8I, EVEX, Sched<[WriteMove]>; } @@ -8806,6 +8806,16 @@ defm VPMOVQ2M : avx512_convert_vector_to_mask<0x39, "vpmovq2m", avx512vl_i64_info, HasDQI>, VEX_W; +// Patterns for handling sext from a mask register to v16i8/v16i16 when DQI +// is available, but BWI is not. We can't handle this in lowering because +// a target independent DAG combine likes to combine sext and trunc. +let Predicates = [HasDQI, NoBWI] in { + def : Pat<(v16i8 (sext (v16i1 VK16:$src))), + (VPMOVDBZrr (v16i32 (VPMOVM2DZrr VK16:$src)))>; + def : Pat<(v16i16 (sext (v16i1 VK16:$src))), + (VPMOVDWZrr (v16i32 (VPMOVM2DZrr VK16:$src)))>; +} + //===----------------------------------------------------------------------===// // AVX-512 - COMPRESS and EXPAND //