@@ -55774,6 +55774,22 @@ static SDValue combineConcatVectorOps(const SDLoc &DL, MVT VT,
55774
55774
}
55775
55775
break;
55776
55776
case ISD::VSELECT:
55777
+ if (!IsSplat && Subtarget.hasAVX512() &&
55778
+ (VT.is256BitVector() ||
55779
+ (VT.is512BitVector() && Subtarget.useAVX512Regs())) &&
55780
+ (EltSizeInBits >= 32 || Subtarget.hasBWI())) {
55781
+ EVT SelVT = Ops[0].getOperand(0).getValueType();
55782
+ if (SelVT.getVectorElementType() == MVT::i1) {
55783
+ SelVT = EVT::getVectorVT(*DAG.getContext(), MVT::i1,
55784
+ Ops.size() * SelVT.getVectorNumElements());
55785
+ if (DAG.getTargetLoweringInfo().isTypeLegal(SelVT))
55786
+ return DAG.getNode(Op0.getOpcode(), DL, VT,
55787
+ ConcatSubOperand(SelVT.getSimpleVT(), Ops, 0),
55788
+ ConcatSubOperand(VT, Ops, 1),
55789
+ ConcatSubOperand(VT, Ops, 2));
55790
+ }
55791
+ }
55792
+ [[fallthrough]];
55777
55793
case X86ISD::BLENDV:
55778
55794
if (!IsSplat && VT.is256BitVector() && Ops.size() == 2 &&
55779
55795
(EltSizeInBits >= 32 || Subtarget.hasInt256()) &&
@@ -55830,13 +55846,28 @@ static SDValue combineCONCAT_VECTORS(SDNode *N, SelectionDAG &DAG,
55830
55846
EVT VT = N->getValueType(0);
55831
55847
EVT SrcVT = N->getOperand(0).getValueType();
55832
55848
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
55849
+ SmallVector<SDValue, 4> Ops(N->op_begin(), N->op_end());
55833
55850
55834
- // Don't do anything for i1 vectors.
55835
- if (VT.getVectorElementType() == MVT::i1)
55851
+ if (VT.getVectorElementType() == MVT::i1) {
55852
+ // Attempt to constant fold.
55853
+ unsigned SubSizeInBits = SrcVT.getSizeInBits();
55854
+ APInt Constant = APInt::getZero(VT.getSizeInBits());
55855
+ for (unsigned I = 0, E = Ops.size(); I != E; ++I) {
55856
+ auto *C = dyn_cast<ConstantSDNode>(peekThroughBitcasts(Ops[I]));
55857
+ if (!C) break;
55858
+ Constant.insertBits(C->getAPIntValue(), I * SubSizeInBits);
55859
+ if (I == (E - 1)) {
55860
+ EVT IntVT = EVT::getIntegerVT(*DAG.getContext(), VT.getSizeInBits());
55861
+ if (TLI.isTypeLegal(IntVT))
55862
+ return DAG.getBitcast(VT, DAG.getConstant(Constant, SDLoc(N), IntVT));
55863
+ }
55864
+ }
55865
+
55866
+ // Don't do anything else for i1 vectors.
55836
55867
return SDValue();
55868
+ }
55837
55869
55838
55870
if (Subtarget.hasAVX() && TLI.isTypeLegal(VT) && TLI.isTypeLegal(SrcVT)) {
55839
- SmallVector<SDValue, 4> Ops(N->op_begin(), N->op_end());
55840
55871
if (SDValue R = combineConcatVectorOps(SDLoc(N), VT.getSimpleVT(), Ops, DAG,
55841
55872
DCI, Subtarget))
55842
55873
return R;
0 commit comments