Skip to content

Commit cb51265

Browse files
fix reviews
1 parent 1fef3b3 commit cb51265

File tree

3 files changed

+504
-205
lines changed

3 files changed

+504
-205
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55491,14 +55491,22 @@ static SDValue combineAVX512SetCCToKMOV(EVT VT, SDValue Op0, ISD::CondCode CC,
5549155491
break;
5549255492
}
5549355493

55494-
if (EltBits[I] != 1ULL << (N + I))
55494+
if (!EltBits[I].isOneBitSet(N + I))
5549555495
return SDValue();
5549655496
}
5549755497

55498-
SDValue BroadcastOp = Broadcast.getOpcode() == X86ISD::VBROADCAST
55499-
? Broadcast.getOperand(0)
55500-
: Broadcast.getOperand(1);
55501-
MVT BroadcastOpVT = BroadcastOp.getSimpleValueType();
55498+
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
55499+
const DataLayout &DL = DAG.getDataLayout();
55500+
MVT VecIdxTy = TLI.getVectorIdxTy(DL);
55501+
MVT BroadcastOpVT = Broadcast.getSimpleValueType().getVectorElementType();
55502+
SDValue BroadcastOp;
55503+
if (Broadcast.getOpcode() != X86ISD::VBROADCAST) {
55504+
BroadcastOp = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, BroadcastOpVT,
55505+
Broadcast, DAG.getConstant(0, DL, VecIdxTy));
55506+
} else {
55507+
BroadcastOp = Broadcast.getOperand(0);
55508+
}
55509+
5550255510
SDValue Masked = BroadcastOp;
5550355511
if (N != 0) {
5550455512
unsigned Mask = (1ULL << Len) - 1;
@@ -55507,17 +55515,17 @@ static SDValue combineAVX512SetCCToKMOV(EVT VT, SDValue Op0, ISD::CondCode CC,
5550755515
Masked = DAG.getNode(ISD::AND, DL, BroadcastOpVT, ShiftedValue,
5550855516
DAG.getConstant(Mask, DL, BroadcastOpVT));
5550955517
}
55518+
// We can't extract more than 16 bits using this pattern, because 2^{17} will
55519+
// not fit in an i16 and a vXi32 where X > 16 is more than 512 bits.
5551055520
SDValue Trunc = DAG.getAnyExtOrTrunc(Masked, DL, MVT::i16);
5551155521
SDValue Bitcast = DAG.getNode(ISD::BITCAST, DL, MVT::v16i1, Trunc);
55512-
MVT PtrTy = DAG.getTargetLoweringInfo().getPointerTy(DAG.getDataLayout());
55522+
MVT PtrTy = TLI.getPointerTy(DL);
5551355523

5551455524
if (CC == ISD::SETEQ)
55515-
Bitcast = DAG.getNode(
55516-
ISD::XOR, DL, MVT::v16i1, Bitcast,
55517-
DAG.getSplatBuildVector(
55518-
MVT::v16i1, DL,
55519-
DAG.getConstant(APInt::getAllOnes(PtrTy.getSizeInBits()), DL,
55520-
PtrTy)));
55525+
Bitcast =
55526+
DAG.getNode(ISD::XOR, DL, MVT::v16i1, Bitcast,
55527+
DAG.getSplatBuildVector(MVT::v16i1, DL,
55528+
DAG.getAllOnesConstant(DL, PtrTy)));
5552155529

5552255530
if (VT != MVT::v16i1)
5552355531
return DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, VT, Bitcast,
@@ -55659,11 +55667,10 @@ static SDValue combineSetCC(SDNode *N, SelectionDAG &DAG,
5565955667
return Op0.getOperand(0);
5566055668
}
5566155669

55662-
if (IsVZero1) {
55670+
if (IsVZero1)
5566355671
if (SDValue V =
5566455672
combineAVX512SetCCToKMOV(VT, Op0, TmpCC, DL, DAG, Subtarget))
5566555673
return V;
55666-
}
5566755674
}
5566855675

5566955676
// Try and make unsigned vector comparison signed. On pre AVX512 targets there

0 commit comments

Comments
 (0)