Skip to content

Commit 7ccb31a

Browse files
committed
[X86] splitVectorOp - share the same SDLoc argument instead of recreating it over and over again.
1 parent d84252e commit 7ccb31a

File tree

1 file changed

+50
-45
lines changed

1 file changed

+50
-45
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 50 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4070,10 +4070,9 @@ static std::pair<SDValue, SDValue> splitVector(SDValue Op, SelectionDAG &DAG,
40704070
}
40714071

40724072
/// Break an operation into 2 half sized ops and then concatenate the results.
4073-
static SDValue splitVectorOp(SDValue Op, SelectionDAG &DAG) {
4073+
static SDValue splitVectorOp(SDValue Op, SelectionDAG &DAG, const SDLoc &dl) {
40744074
unsigned NumOps = Op.getNumOperands();
40754075
EVT VT = Op.getValueType();
4076-
SDLoc dl(Op);
40774076

40784077
// Extract the LHS Lo/Hi vectors
40794078
SmallVector<SDValue> LoOps(NumOps, SDValue());
@@ -4096,7 +4095,8 @@ static SDValue splitVectorOp(SDValue Op, SelectionDAG &DAG) {
40964095

40974096
/// Break an unary integer operation into 2 half sized ops and then
40984097
/// concatenate the result back.
4099-
static SDValue splitVectorIntUnary(SDValue Op, SelectionDAG &DAG) {
4098+
static SDValue splitVectorIntUnary(SDValue Op, SelectionDAG &DAG,
4099+
const SDLoc &dl) {
41004100
// Make sure we only try to split 256/512-bit types to avoid creating
41014101
// narrow vectors.
41024102
EVT VT = Op.getValueType();
@@ -4107,19 +4107,20 @@ static SDValue splitVectorIntUnary(SDValue Op, SelectionDAG &DAG) {
41074107
assert(Op.getOperand(0).getValueType().getVectorNumElements() ==
41084108
VT.getVectorNumElements() &&
41094109
"Unexpected VTs!");
4110-
return splitVectorOp(Op, DAG);
4110+
return splitVectorOp(Op, DAG, dl);
41114111
}
41124112

41134113
/// Break a binary integer operation into 2 half sized ops and then
41144114
/// concatenate the result back.
4115-
static SDValue splitVectorIntBinary(SDValue Op, SelectionDAG &DAG) {
4115+
static SDValue splitVectorIntBinary(SDValue Op, SelectionDAG &DAG,
4116+
const SDLoc &dl) {
41164117
// Assert that all the types match.
41174118
EVT VT = Op.getValueType();
41184119
(void)VT;
41194120
assert(Op.getOperand(0).getValueType() == VT &&
41204121
Op.getOperand(1).getValueType() == VT && "Unexpected VTs!");
41214122
assert((VT.is256BitVector() || VT.is512BitVector()) && "Unsupported VT!");
4122-
return splitVectorOp(Op, DAG);
4123+
return splitVectorOp(Op, DAG, dl);
41234124
}
41244125

41254126
// Helper for splitting operands of an operation to legal target size and
@@ -20075,7 +20076,7 @@ static SDValue LowerAVXExtend(SDValue Op, SelectionDAG &DAG,
2007520076

2007620077
if (VT == MVT::v32i16 && !Subtarget.hasBWI()) {
2007720078
assert(InVT == MVT::v32i8 && "Unexpected VT!");
20078-
return splitVectorIntUnary(Op, DAG);
20079+
return splitVectorIntUnary(Op, DAG, dl);
2007920080
}
2008020081

2008120082
if (Subtarget.hasInt256())
@@ -20656,7 +20657,7 @@ SDValue X86TargetLowering::LowerTRUNCATE(SDValue Op, SelectionDAG &DAG) const {
2065620657
if (Subtarget.hasAVX512()) {
2065720658
if (InVT == MVT::v32i16 && !Subtarget.hasBWI()) {
2065820659
assert(VT == MVT::v32i8 && "Unexpected VT!");
20659-
return splitVectorIntUnary(Op, DAG);
20660+
return splitVectorIntUnary(Op, DAG, DL);
2066020661
}
2066120662

2066220663
// word to byte only under BWI. Otherwise we have to promoted to v16i32
@@ -21636,7 +21637,8 @@ SDValue X86TargetLowering::LowerFP_TO_BF16(SDValue Op,
2163621637

2163721638
/// Depending on uarch and/or optimizing for size, we might prefer to use a
2163821639
/// vector operation in place of the typical scalar operation.
21639-
static SDValue lowerAddSubToHorizontalOp(SDValue Op, SelectionDAG &DAG,
21640+
static SDValue lowerAddSubToHorizontalOp(SDValue Op, const SDLoc &DL,
21641+
SelectionDAG &DAG,
2164021642
const X86Subtarget &Subtarget) {
2164121643
// If both operands have other uses, this is probably not profitable.
2164221644
SDValue LHS = Op.getOperand(0);
@@ -21692,7 +21694,6 @@ static SDValue lowerAddSubToHorizontalOp(SDValue Op, SelectionDAG &DAG,
2169221694

2169321695
// Creating a 256-bit horizontal op would be wasteful, and there is no 512-bit
2169421696
// equivalent, so extract the 256/512-bit source op to 128-bit if we can.
21695-
SDLoc DL(Op);
2169621697
if (BitWidth == 256 || BitWidth == 512) {
2169721698
unsigned LaneIdx = LExtIndex / NumEltsPerLane;
2169821699
X = extract128BitVector(X, LaneIdx * NumEltsPerLane, DAG, DL);
@@ -21713,7 +21714,7 @@ static SDValue lowerAddSubToHorizontalOp(SDValue Op, SelectionDAG &DAG,
2171321714
SDValue X86TargetLowering::lowerFaddFsub(SDValue Op, SelectionDAG &DAG) const {
2171421715
assert((Op.getValueType() == MVT::f32 || Op.getValueType() == MVT::f64) &&
2171521716
"Only expecting float/double");
21716-
return lowerAddSubToHorizontalOp(Op, DAG, Subtarget);
21717+
return lowerAddSubToHorizontalOp(Op, SDLoc(Op), DAG, Subtarget);
2171721718
}
2171821719

2171921720
/// ISD::FROUND is defined to round to nearest with ties rounding away from 0.
@@ -24470,7 +24471,7 @@ static SDValue LowerSIGN_EXTEND(SDValue Op, const X86Subtarget &Subtarget,
2447024471

2447124472
if (VT == MVT::v32i16 && !Subtarget.hasBWI()) {
2447224473
assert(InVT == MVT::v32i8 && "Unexpected VT!");
24473-
return splitVectorIntUnary(Op, DAG);
24474+
return splitVectorIntUnary(Op, DAG, dl);
2447424475
}
2447524476

2447624477
if (Subtarget.hasInt256())
@@ -27833,7 +27834,7 @@ static SDValue LowerVectorCTLZ_AVX512CDI(SDValue Op, SelectionDAG &DAG,
2783327834
// Split vector, it's Lo and Hi parts will be handled in next iteration.
2783427835
if (NumElems > 16 ||
2783527836
(NumElems == 16 && !Subtarget.canExtendTo512DQ()))
27836-
return splitVectorIntUnary(Op, DAG);
27837+
return splitVectorIntUnary(Op, DAG, dl);
2783727838

2783827839
MVT NewVT = MVT::getVectorVT(MVT::i32, NumElems);
2783927840
assert((NewVT.is256BitVector() || NewVT.is512BitVector()) &&
@@ -27943,11 +27944,11 @@ static SDValue LowerVectorCTLZ(SDValue Op, const SDLoc &DL,
2794327944

2794427945
// Decompose 256-bit ops into smaller 128-bit ops.
2794527946
if (VT.is256BitVector() && !Subtarget.hasInt256())
27946-
return splitVectorIntUnary(Op, DAG);
27947+
return splitVectorIntUnary(Op, DAG, DL);
2794727948

2794827949
// Decompose 512-bit ops into smaller 256-bit ops.
2794927950
if (VT.is512BitVector() && !Subtarget.hasBWI())
27950-
return splitVectorIntUnary(Op, DAG);
27951+
return splitVectorIntUnary(Op, DAG, DL);
2795127952

2795227953
assert(Subtarget.hasSSSE3() && "Expected SSSE3 support for PSHUFB");
2795327954
return LowerVectorCTLZInRegLUT(Op, DL, Subtarget, DAG);
@@ -28020,16 +28021,18 @@ static SDValue LowerCTTZ(SDValue Op, const X86Subtarget &Subtarget,
2802028021
static SDValue lowerAddSub(SDValue Op, SelectionDAG &DAG,
2802128022
const X86Subtarget &Subtarget) {
2802228023
MVT VT = Op.getSimpleValueType();
28024+
SDLoc DL(Op);
28025+
2802328026
if (VT == MVT::i16 || VT == MVT::i32)
28024-
return lowerAddSubToHorizontalOp(Op, DAG, Subtarget);
28027+
return lowerAddSubToHorizontalOp(Op, DL, DAG, Subtarget);
2802528028

2802628029
if (VT == MVT::v32i16 || VT == MVT::v64i8)
28027-
return splitVectorIntBinary(Op, DAG);
28030+
return splitVectorIntBinary(Op, DAG, DL);
2802828031

2802928032
assert(Op.getSimpleValueType().is256BitVector() &&
2803028033
Op.getSimpleValueType().isInteger() &&
2803128034
"Only handle AVX 256-bit vector integer operation");
28032-
return splitVectorIntBinary(Op, DAG);
28035+
return splitVectorIntBinary(Op, DAG, DL);
2803328036
}
2803428037

2803528038
static SDValue LowerADDSAT_SUBSAT(SDValue Op, SelectionDAG &DAG,
@@ -28043,7 +28046,7 @@ static SDValue LowerADDSAT_SUBSAT(SDValue Op, SelectionDAG &DAG,
2804328046
(VT.is256BitVector() && !Subtarget.hasInt256())) {
2804428047
assert(Op.getSimpleValueType().isInteger() &&
2804528048
"Only handle AVX vector integer operation");
28046-
return splitVectorIntBinary(Op, DAG);
28049+
return splitVectorIntBinary(Op, DAG, DL);
2804728050
}
2804828051

2804928052
// Avoid the generic expansion with min/max if we don't have pminu*/pmaxu*.
@@ -28105,10 +28108,11 @@ static SDValue LowerADDSAT_SUBSAT(SDValue Op, SelectionDAG &DAG,
2810528108
static SDValue LowerABS(SDValue Op, const X86Subtarget &Subtarget,
2810628109
SelectionDAG &DAG) {
2810728110
MVT VT = Op.getSimpleValueType();
28111+
SDLoc DL(Op);
28112+
2810828113
if (VT == MVT::i16 || VT == MVT::i32 || VT == MVT::i64) {
2810928114
// Since X86 does not have CMOV for 8-bit integer, we don't convert
2811028115
// 8-bit integer abs to NEG and CMOV.
28111-
SDLoc DL(Op);
2811228116
SDValue N0 = Op.getOperand(0);
2811328117
SDValue Neg = DAG.getNode(X86ISD::SUB, DL, DAG.getVTList(VT, MVT::i32),
2811428118
DAG.getConstant(0, DL, VT), N0);
@@ -28119,7 +28123,6 @@ static SDValue LowerABS(SDValue Op, const X86Subtarget &Subtarget,
2811928123

2812028124
// ABS(vXi64 X) --> VPBLENDVPD(X, 0-X, X).
2812128125
if ((VT == MVT::v2i64 || VT == MVT::v4i64) && Subtarget.hasSSE41()) {
28122-
SDLoc DL(Op);
2812328126
SDValue Src = Op.getOperand(0);
2812428127
SDValue Sub =
2812528128
DAG.getNode(ISD::SUB, DL, VT, DAG.getConstant(0, DL, VT), Src);
@@ -28129,11 +28132,11 @@ static SDValue LowerABS(SDValue Op, const X86Subtarget &Subtarget,
2812928132
if (VT.is256BitVector() && !Subtarget.hasInt256()) {
2813028133
assert(VT.isInteger() &&
2813128134
"Only handle AVX 256-bit vector integer operation");
28132-
return splitVectorIntUnary(Op, DAG);
28135+
return splitVectorIntUnary(Op, DAG, DL);
2813328136
}
2813428137

2813528138
if ((VT == MVT::v32i16 || VT == MVT::v64i8) && !Subtarget.hasBWI())
28136-
return splitVectorIntUnary(Op, DAG);
28139+
return splitVectorIntUnary(Op, DAG, DL);
2813728140

2813828141
// Default to expand.
2813928142
return SDValue();
@@ -28142,13 +28145,14 @@ static SDValue LowerABS(SDValue Op, const X86Subtarget &Subtarget,
2814228145
static SDValue LowerAVG(SDValue Op, const X86Subtarget &Subtarget,
2814328146
SelectionDAG &DAG) {
2814428147
MVT VT = Op.getSimpleValueType();
28148+
SDLoc DL(Op);
2814528149

2814628150
// For AVX1 cases, split to use legal ops.
2814728151
if (VT.is256BitVector() && !Subtarget.hasInt256())
28148-
return splitVectorIntBinary(Op, DAG);
28152+
return splitVectorIntBinary(Op, DAG, DL);
2814928153

2815028154
if (VT == MVT::v32i16 || VT == MVT::v64i8)
28151-
return splitVectorIntBinary(Op, DAG);
28155+
return splitVectorIntBinary(Op, DAG, DL);
2815228156

2815328157
// Default to expand.
2815428158
return SDValue();
@@ -28157,13 +28161,14 @@ static SDValue LowerAVG(SDValue Op, const X86Subtarget &Subtarget,
2815728161
static SDValue LowerMINMAX(SDValue Op, const X86Subtarget &Subtarget,
2815828162
SelectionDAG &DAG) {
2815928163
MVT VT = Op.getSimpleValueType();
28164+
SDLoc DL(Op);
2816028165

2816128166
// For AVX1 cases, split to use legal ops.
2816228167
if (VT.is256BitVector() && !Subtarget.hasInt256())
28163-
return splitVectorIntBinary(Op, DAG);
28168+
return splitVectorIntBinary(Op, DAG, DL);
2816428169

2816528170
if (VT == MVT::v32i16 || VT == MVT::v64i8)
28166-
return splitVectorIntBinary(Op, DAG);
28171+
return splitVectorIntBinary(Op, DAG, DL);
2816728172

2816828173
// Default to expand.
2816928174
return SDValue();
@@ -28320,15 +28325,15 @@ static SDValue LowerFMINIMUM_FMAXIMUM(SDValue Op, const X86Subtarget &Subtarget,
2832028325
static SDValue LowerABD(SDValue Op, const X86Subtarget &Subtarget,
2832128326
SelectionDAG &DAG) {
2832228327
MVT VT = Op.getSimpleValueType();
28328+
SDLoc dl(Op);
2832328329

2832428330
// For AVX1 cases, split to use legal ops.
2832528331
if (VT.is256BitVector() && !Subtarget.hasInt256())
28326-
return splitVectorIntBinary(Op, DAG);
28332+
return splitVectorIntBinary(Op, DAG, dl);
2832728333

2832828334
if ((VT == MVT::v32i16 || VT == MVT::v64i8) && !Subtarget.useBWIRegs())
28329-
return splitVectorIntBinary(Op, DAG);
28335+
return splitVectorIntBinary(Op, DAG, dl);
2833028336

28331-
SDLoc dl(Op);
2833228337
bool IsSigned = Op.getOpcode() == ISD::ABDS;
2833328338
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
2833428339

@@ -28371,10 +28376,10 @@ static SDValue LowerMUL(SDValue Op, const X86Subtarget &Subtarget,
2837128376

2837228377
// Decompose 256-bit ops into 128-bit ops.
2837328378
if (VT.is256BitVector() && !Subtarget.hasInt256())
28374-
return splitVectorIntBinary(Op, DAG);
28379+
return splitVectorIntBinary(Op, DAG, dl);
2837528380

2837628381
if ((VT == MVT::v32i16 || VT == MVT::v64i8) && !Subtarget.hasBWI())
28377-
return splitVectorIntBinary(Op, DAG);
28382+
return splitVectorIntBinary(Op, DAG, dl);
2837828383

2837928384
SDValue A = Op.getOperand(0);
2838028385
SDValue B = Op.getOperand(1);
@@ -28597,10 +28602,10 @@ static SDValue LowerMULH(SDValue Op, const X86Subtarget &Subtarget,
2859728602

2859828603
// Decompose 256-bit ops into 128-bit ops.
2859928604
if (VT.is256BitVector() && !Subtarget.hasInt256())
28600-
return splitVectorIntBinary(Op, DAG);
28605+
return splitVectorIntBinary(Op, DAG, dl);
2860128606

2860228607
if ((VT == MVT::v32i16 || VT == MVT::v64i8) && !Subtarget.hasBWI())
28603-
return splitVectorIntBinary(Op, DAG);
28608+
return splitVectorIntBinary(Op, DAG, dl);
2860428609

2860528610
if (VT == MVT::v4i32 || VT == MVT::v8i32 || VT == MVT::v16i32) {
2860628611
assert((VT == MVT::v4i32 && Subtarget.hasSSE2()) ||
@@ -29778,10 +29783,10 @@ static SDValue LowerShift(SDValue Op, const X86Subtarget &Subtarget,
2977829783

2977929784
// Decompose 256-bit shifts into 128-bit shifts.
2978029785
if (VT.is256BitVector())
29781-
return splitVectorIntBinary(Op, DAG);
29786+
return splitVectorIntBinary(Op, DAG, dl);
2978229787

2978329788
if (VT == MVT::v32i16 || VT == MVT::v64i8)
29784-
return splitVectorIntBinary(Op, DAG);
29789+
return splitVectorIntBinary(Op, DAG, dl);
2978529790

2978629791
return SDValue();
2978729792
}
@@ -29858,7 +29863,7 @@ static SDValue LowerFunnelShift(SDValue Op, const X86Subtarget &Subtarget,
2985829863
EltSizeInBits < 32)) {
2985929864
// Pre-mask the amount modulo using the wider vector.
2986029865
Op = DAG.getNode(Op.getOpcode(), DL, VT, Op0, Op1, AmtMod);
29861-
return splitVectorOp(Op, DAG);
29866+
return splitVectorOp(Op, DAG, DL);
2986229867
}
2986329868

2986429869
// Attempt to fold scalar shift as unpack(y,x) << zext(splat(z))
@@ -30020,7 +30025,7 @@ static SDValue LowerRotate(SDValue Op, const X86Subtarget &Subtarget,
3002030025

3002130026
// Split 256-bit integers on XOP/pre-AVX2 targets.
3002230027
if (VT.is256BitVector() && (Subtarget.hasXOP() || !Subtarget.hasAVX2()))
30023-
return splitVectorIntBinary(Op, DAG);
30028+
return splitVectorIntBinary(Op, DAG, DL);
3002430029

3002530030
// XOP has 128-bit vector variable + immediate rotates.
3002630031
// +ve/-ve Amt = rotate left/right - just need to handle ISD::ROTL.
@@ -30056,7 +30061,7 @@ static SDValue LowerRotate(SDValue Op, const X86Subtarget &Subtarget,
3005630061

3005730062
// Split 512-bit integers on non 512-bit BWI targets.
3005830063
if (VT.is512BitVector() && !Subtarget.useBWIRegs())
30059-
return splitVectorIntBinary(Op, DAG);
30064+
return splitVectorIntBinary(Op, DAG, DL);
3006030065

3006130066
assert(
3006230067
(VT == MVT::v4i32 || VT == MVT::v8i16 || VT == MVT::v16i8 ||
@@ -31136,11 +31141,11 @@ static SDValue LowerVectorCTPOP(SDValue Op, const SDLoc &DL,
3113631141

3113731142
// Decompose 256-bit ops into smaller 128-bit ops.
3113831143
if (VT.is256BitVector() && !Subtarget.hasInt256())
31139-
return splitVectorIntUnary(Op, DAG);
31144+
return splitVectorIntUnary(Op, DAG, DL);
3114031145

3114131146
// Decompose 512-bit ops into smaller 256-bit ops.
3114231147
if (VT.is512BitVector() && !Subtarget.hasBWI())
31143-
return splitVectorIntUnary(Op, DAG);
31148+
return splitVectorIntUnary(Op, DAG, DL);
3114431149

3114531150
// For element types greater than i8, do vXi8 pop counts and a bytesum.
3114631151
if (VT.getScalarType() != MVT::i8) {
@@ -31264,7 +31269,7 @@ static SDValue LowerBITREVERSE_XOP(SDValue Op, SelectionDAG &DAG) {
3126431269

3126531270
// Decompose 256-bit ops into smaller 128-bit ops.
3126631271
if (VT.is256BitVector())
31267-
return splitVectorIntUnary(Op, DAG);
31272+
return splitVectorIntUnary(Op, DAG, DL);
3126831273

3126931274
assert(VT.is128BitVector() &&
3127031275
"Only 128-bit vector bitreverse lowering supported.");
@@ -31303,11 +31308,11 @@ static SDValue LowerBITREVERSE(SDValue Op, const X86Subtarget &Subtarget,
3130331308

3130431309
// Split 512-bit ops without BWI so that we can still use the PSHUFB lowering.
3130531310
if (VT.is512BitVector() && !Subtarget.hasBWI())
31306-
return splitVectorIntUnary(Op, DAG);
31311+
return splitVectorIntUnary(Op, DAG, DL);
3130731312

3130831313
// Decompose 256-bit ops into smaller 128-bit ops on pre-AVX2.
3130931314
if (VT.is256BitVector() && !Subtarget.hasInt256())
31310-
return splitVectorIntUnary(Op, DAG);
31315+
return splitVectorIntUnary(Op, DAG, DL);
3131131316

3131231317
// Lower vXi16/vXi32/vXi64 as BSWAP + vXi8 BITREVERSE.
3131331318
if (VT.getScalarType() != MVT::i8) {
@@ -55980,7 +55985,7 @@ static SDValue combineEXTRACT_SUBVECTOR(SDNode *N, SelectionDAG &DAG,
5598055985
if (isConcatenatedNot(InVecBC.getOperand(0)) ||
5598155986
isConcatenatedNot(InVecBC.getOperand(1))) {
5598255987
// extract (and v4i64 X, (not (concat Y1, Y2))), n -> andnp v2i64 X(n), Y1
55983-
SDValue Concat = splitVectorIntBinary(InVecBC, DAG);
55988+
SDValue Concat = splitVectorIntBinary(InVecBC, DAG, SDLoc(InVecBC));
5598455989
return DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, VT,
5598555990
DAG.getBitcast(InVecVT, Concat), N->getOperand(1));
5598655991
}

0 commit comments

Comments
 (0)