Skip to content

Commit

Permalink
[X86] combineExtractWithShuffle - pull out repeated getSizeInBits() c…
Browse files Browse the repository at this point in the history
…all. NFC.
  • Loading branch information
RKSimon committed Mar 13, 2020
1 parent fe047fb commit 846c614
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions llvm/lib/Target/X86/X86ISelLowering.cpp
Expand Up @@ -37847,6 +37847,7 @@ static SDValue combineExtractWithShuffle(SDNode *N, SelectionDAG &DAG,
EVT VT = N->getValueType(0);
EVT SrcVT = Src.getValueType();
EVT SrcSVT = SrcVT.getVectorElementType();
unsigned SrcEltBits = SrcSVT.getSizeInBits();
unsigned NumSrcElts = SrcVT.getVectorNumElements();

// Don't attempt this for boolean mask vectors or unknown extraction indices.
Expand All @@ -37867,9 +37868,9 @@ static SDValue combineExtractWithShuffle(SDNode *N, SelectionDAG &DAG,

EVT SrcOpVT = SrcOp.getValueType();
if (SrcOpVT.isScalarInteger() && VT.isInteger() &&
(SrcOpVT.getSizeInBits() % SrcSVT.getSizeInBits()) == 0) {
unsigned Scale = SrcOpVT.getSizeInBits() / SrcSVT.getSizeInBits();
unsigned Offset = IdxC.urem(Scale) * SrcSVT.getSizeInBits();
(SrcOpVT.getSizeInBits() % SrcEltBits) == 0) {
unsigned Scale = SrcOpVT.getSizeInBits() / SrcEltBits;
unsigned Offset = IdxC.urem(Scale) * SrcEltBits;
// TODO support non-zero offsets.
if (Offset == 0) {
SrcOp = DAG.getZExtOrTrunc(SrcOp, dl, SrcVT.getScalarType());
Expand Down Expand Up @@ -37900,10 +37901,10 @@ static SDValue combineExtractWithShuffle(SDNode *N, SelectionDAG &DAG,
// TODO: Move to DAGCombine?
if (SrcBC.getOpcode() == ISD::SCALAR_TO_VECTOR && VT.isInteger() &&
SrcBC.getValueType().isInteger() &&
(SrcBC.getScalarValueSizeInBits() % SrcSVT.getSizeInBits()) == 0 &&
(SrcBC.getScalarValueSizeInBits() % SrcEltBits) == 0 &&
SrcBC.getScalarValueSizeInBits() ==
SrcBC.getOperand(0).getValueSizeInBits()) {
unsigned Scale = SrcBC.getScalarValueSizeInBits() / SrcSVT.getSizeInBits();
unsigned Scale = SrcBC.getScalarValueSizeInBits() / SrcEltBits;
if (IdxC.ult(Scale)) {
unsigned Offset = IdxC.getZExtValue() * SrcVT.getScalarSizeInBits();
SDValue Scl = SrcBC.getOperand(0);
Expand Down Expand Up @@ -37996,8 +37997,7 @@ static SDValue combineExtractWithShuffle(SDNode *N, SelectionDAG &DAG,

if ((SrcVT == MVT::v8i16 && Subtarget.hasSSE2()) ||
(SrcVT == MVT::v16i8 && Subtarget.hasSSE41())) {
assert(VT.getSizeInBits() >= SrcSVT.getSizeInBits() &&
"Unexpected extraction type");
assert(VT.getSizeInBits() >= SrcEltBits && "Unexpected extraction type");
unsigned OpCode = (SrcVT == MVT::v8i16 ? X86ISD::PEXTRW : X86ISD::PEXTRB);
SrcOp = DAG.getBitcast(SrcVT, SrcOp);
SDValue ExtOp = DAG.getNode(OpCode, dl, MVT::i32, SrcOp,
Expand Down

0 comments on commit 846c614

Please sign in to comment.