@@ -13342,7 +13342,6 @@ SDValue SITargetLowering::performXorCombine(SDNode *N,
13342
13342
// v2i32 (xor (vselect cc, x, y), K) ->
13343
13343
// (v2i32 svelect cc, (xor x, K), (xor y, K)) This enables the xor to be
13344
13344
// replaced with source modifiers when the select is lowered to CNDMASK.
13345
- // TODO REMOVE: prevents regressions in fneg-modifier-casting.ll
13346
13345
unsigned Opc = LHS.getOpcode();
13347
13346
if(((Opc == ISD::VSELECT && VT==MVT::v2i32) || (Opc == ISD::SELECT && VT==MVT::i64)) && CRHS && CRHS->getAPIntValue().isSignMask()) {
13348
13347
SDValue CC = LHS->getOperand(0);
@@ -14320,165 +14319,126 @@ bool SITargetLowering::shouldExpandVectorDynExt(SDNode *N) const {
14320
14319
EltSize, NumElem, Idx->isDivergent(), getSubtarget());
14321
14320
}
14322
14321
14323
- // SDValue
14324
- // SITargetLowering::performBuildVectorCombine(SDNode *N,
14325
- // DAGCombinerInfo &DCI) const {
14326
- // // if (N->use_empty())
14327
- // // return SDValue();
14328
-
14329
- // // if(!N->getValueType(0).isFloatingPoint())
14330
- // // return SDValue();
14331
-
14332
- // // SelectionDAG &DAG = DCI.DAG;
14333
-
14334
- // // // Iterate the operands. Check if source modifier. If so, propogate the
14335
- // // source
14336
- // // // modifier to the user and the srcmod from the BUILD_VECTOR element.
14337
- // // for (unsigned I = 0; I < N->getNumOperands(); I++) {
14338
- // // SDValue E = N->getOperand(I);
14339
- // // if (E->getOpcode() != ISD::FNEG && E->getOpcode() != ISD::ABS)
14340
- // // continue;
14341
-
14342
- // // // Users through which we can propogate will include users of
14343
- // // // extract_element on this vector, so need to peek-through.
14344
- // // }
14345
-
14346
- // // SmallVector<SDNode*, 4> UsersToModify;
14347
-
14348
- // // // If the use of the BUILD_VECTOR supports source mods it can be
14349
- // // propogated. for (SDNode *U : N->users()) {
14350
- // // if(!U->getOpcode() == ISD::EXTRACT_VECTOR_ELT)
14351
- // // if (!allUsesHaveSourceMods(U))
14352
- // // continue;
14353
- // // UsersToModify.push_back(U);
14354
- // // }
14355
-
14356
- // // for(auto Node: UsersToModify) {
14357
-
14358
- // // }
14359
-
14360
- // return SDValue();
14361
- // }
14362
-
14363
- SDValue SITargetLowering::performExtractVectorEltCombine(
14364
- SDNode * N, DAGCombinerInfo & DCI) const {
14365
- SDValue Vec = N->getOperand(0);
14366
- SelectionDAG &DAG = DCI.DAG;
14367
-
14368
- EVT VecVT = Vec.getValueType();
14369
- EVT VecEltVT = VecVT.getVectorElementType();
14370
- EVT ResVT = N->getValueType(0);
14322
+ SDValue
14323
+ SITargetLowering::performExtractVectorEltCombine(SDNode *N,
14324
+ DAGCombinerInfo &DCI) const {
14325
+ SDValue Vec = N->getOperand(0);
14326
+ SelectionDAG &DAG = DCI.DAG;
14371
14327
14372
- unsigned VecSize = VecVT.getSizeInBits();
14373
- unsigned VecEltSize = VecEltVT.getSizeInBits();
14328
+ EVT VecVT = Vec.getValueType();
14329
+ EVT VecEltVT = VecVT.getVectorElementType();
14330
+ EVT ResVT = N->getValueType(0);
14374
14331
14375
- if ((Vec.getOpcode() == ISD::FNEG || Vec.getOpcode() == ISD::FABS) &&
14376
- allUsesHaveSourceMods(N)) {
14377
- SDLoc SL(N);
14378
- SDValue Idx = N->getOperand(1);
14379
- SDValue Elt = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, SL, ResVT,
14380
- Vec.getOperand(0), Idx);
14381
- return DAG.getNode(Vec.getOpcode(), SL, ResVT, Elt);
14382
- }
14383
-
14384
- // ScalarRes = EXTRACT_VECTOR_ELT ((vector-BINOP Vec1, Vec2), Idx)
14385
- // =>
14386
- // Vec1Elt = EXTRACT_VECTOR_ELT(Vec1, Idx)
14387
- // Vec2Elt = EXTRACT_VECTOR_ELT(Vec2, Idx)
14388
- // ScalarRes = scalar-BINOP Vec1Elt, Vec2Elt
14389
- if (Vec.hasOneUse() && DCI.isBeforeLegalize() && VecEltVT == ResVT) {
14390
- SDLoc SL(N);
14391
- SDValue Idx = N->getOperand(1);
14392
- unsigned Opc = Vec.getOpcode();
14332
+ unsigned VecSize = VecVT.getSizeInBits();
14333
+ unsigned VecEltSize = VecEltVT.getSizeInBits();
14393
14334
14394
- switch (Opc) {
14395
- default:
14396
- break;
14397
- // TODO: Support other binary operations.
14398
- case ISD::FADD:
14399
- case ISD::FSUB:
14400
- case ISD::FMUL:
14401
- case ISD::ADD:
14402
- case ISD::UMIN:
14403
- case ISD::UMAX:
14404
- case ISD::SMIN:
14405
- case ISD::SMAX:
14406
- case ISD::FMAXNUM:
14407
- case ISD::FMINNUM:
14408
- case ISD::FMAXNUM_IEEE:
14409
- case ISD::FMINNUM_IEEE:
14410
- case ISD::FMAXIMUM:
14411
- case ISD::FMINIMUM: {
14412
- SDValue Elt0 = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, SL, ResVT,
14413
- Vec.getOperand(0), Idx);
14414
- SDValue Elt1 = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, SL, ResVT,
14415
- Vec.getOperand(1), Idx);
14416
-
14417
- DCI.AddToWorklist(Elt0.getNode());
14418
- DCI.AddToWorklist(Elt1.getNode());
14419
- return DAG.getNode(Opc, SL, ResVT, Elt0, Elt1, Vec->getFlags());
14420
- }
14421
- }
14422
- }
14335
+ if ((Vec.getOpcode() == ISD::FNEG || Vec.getOpcode() == ISD::FABS) &&
14336
+ allUsesHaveSourceMods(N)) {
14337
+ SDLoc SL(N);
14338
+ SDValue Idx = N->getOperand(1);
14339
+ SDValue Elt =
14340
+ DAG.getNode(ISD::EXTRACT_VECTOR_ELT, SL, ResVT, Vec.getOperand(0), Idx);
14341
+ return DAG.getNode(Vec.getOpcode(), SL, ResVT, Elt);
14342
+ }
14343
+
14344
+ // ScalarRes = EXTRACT_VECTOR_ELT ((vector-BINOP Vec1, Vec2), Idx)
14345
+ // =>
14346
+ // Vec1Elt = EXTRACT_VECTOR_ELT(Vec1, Idx)
14347
+ // Vec2Elt = EXTRACT_VECTOR_ELT(Vec2, Idx)
14348
+ // ScalarRes = scalar-BINOP Vec1Elt, Vec2Elt
14349
+ if (Vec.hasOneUse() && DCI.isBeforeLegalize() && VecEltVT == ResVT) {
14350
+ SDLoc SL(N);
14351
+ SDValue Idx = N->getOperand(1);
14352
+ unsigned Opc = Vec.getOpcode();
14423
14353
14424
- // EXTRACT_VECTOR_ELT (<n x e>, var-idx) => n x select (e, const-idx)
14425
- if (shouldExpandVectorDynExt(N)) {
14426
- SDLoc SL(N);
14427
- SDValue Idx = N->getOperand(1);
14428
- SDValue V;
14429
- for (unsigned I = 0, E = VecVT.getVectorNumElements(); I < E; ++I) {
14430
- SDValue IC = DAG.getVectorIdxConstant(I, SL);
14431
- SDValue Elt = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, SL, ResVT, Vec, IC);
14432
- if (I == 0)
14433
- V = Elt;
14434
- else
14435
- V = DAG.getSelectCC(SL, Idx, IC, Elt, V, ISD::SETEQ);
14436
- }
14437
- return V;
14354
+ switch (Opc) {
14355
+ default:
14356
+ break;
14357
+ // TODO: Support other binary operations.
14358
+ case ISD::FADD:
14359
+ case ISD::FSUB:
14360
+ case ISD::FMUL:
14361
+ case ISD::ADD:
14362
+ case ISD::UMIN:
14363
+ case ISD::UMAX:
14364
+ case ISD::SMIN:
14365
+ case ISD::SMAX:
14366
+ case ISD::FMAXNUM:
14367
+ case ISD::FMINNUM:
14368
+ case ISD::FMAXNUM_IEEE:
14369
+ case ISD::FMINNUM_IEEE:
14370
+ case ISD::FMAXIMUM:
14371
+ case ISD::FMINIMUM: {
14372
+ SDValue Elt0 = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, SL, ResVT,
14373
+ Vec.getOperand(0), Idx);
14374
+ SDValue Elt1 = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, SL, ResVT,
14375
+ Vec.getOperand(1), Idx);
14376
+
14377
+ DCI.AddToWorklist(Elt0.getNode());
14378
+ DCI.AddToWorklist(Elt1.getNode());
14379
+ return DAG.getNode(Opc, SL, ResVT, Elt0, Elt1, Vec->getFlags());
14380
+ }
14381
+ }
14382
+ }
14383
+
14384
+ // EXTRACT_VECTOR_ELT (<n x e>, var-idx) => n x select (e, const-idx)
14385
+ if (shouldExpandVectorDynExt(N)) {
14386
+ SDLoc SL(N);
14387
+ SDValue Idx = N->getOperand(1);
14388
+ SDValue V;
14389
+ for (unsigned I = 0, E = VecVT.getVectorNumElements(); I < E; ++I) {
14390
+ SDValue IC = DAG.getVectorIdxConstant(I, SL);
14391
+ SDValue Elt = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, SL, ResVT, Vec, IC);
14392
+ if (I == 0)
14393
+ V = Elt;
14394
+ else
14395
+ V = DAG.getSelectCC(SL, Idx, IC, Elt, V, ISD::SETEQ);
14438
14396
}
14397
+ return V;
14398
+ }
14439
14399
14440
- if (!DCI.isBeforeLegalize())
14441
- return SDValue();
14442
-
14443
- // Try to turn sub-dword accesses of vectors into accesses of the same
14444
- // 32-bit elements. This exposes more load reduction opportunities by
14445
- // replacing multiple small extract_vector_elements with a single 32-bit
14446
- // extract.
14447
- auto *Idx = dyn_cast<ConstantSDNode>(N->getOperand(1));
14448
- if (isa<MemSDNode>(Vec) && VecEltSize <= 16 && VecEltVT.isByteSized() &&
14449
- VecSize > 32 && VecSize % 32 == 0 && Idx) {
14450
- EVT NewVT = getEquivalentMemType(*DAG.getContext(), VecVT);
14451
-
14452
- unsigned BitIndex = Idx->getZExtValue() * VecEltSize;
14453
- unsigned EltIdx = BitIndex / 32;
14454
- unsigned LeftoverBitIdx = BitIndex % 32;
14455
- SDLoc SL(N);
14400
+ if (!DCI.isBeforeLegalize())
14401
+ return SDValue();
14456
14402
14457
- SDValue Cast = DAG.getNode(ISD::BITCAST, SL, NewVT, Vec);
14458
- DCI.AddToWorklist(Cast.getNode());
14403
+ // Try to turn sub-dword accesses of vectors into accesses of the same
14404
+ // 32-bit elements. This exposes more load reduction opportunities by
14405
+ // replacing multiple small extract_vector_elements with a single 32-bit
14406
+ // extract.
14407
+ auto *Idx = dyn_cast<ConstantSDNode>(N->getOperand(1));
14408
+ if (isa<MemSDNode>(Vec) && VecEltSize <= 16 && VecEltVT.isByteSized() &&
14409
+ VecSize > 32 && VecSize % 32 == 0 && Idx) {
14410
+ EVT NewVT = getEquivalentMemType(*DAG.getContext(), VecVT);
14411
+
14412
+ unsigned BitIndex = Idx->getZExtValue() * VecEltSize;
14413
+ unsigned EltIdx = BitIndex / 32;
14414
+ unsigned LeftoverBitIdx = BitIndex % 32;
14415
+ SDLoc SL(N);
14459
14416
14460
- SDValue Elt = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, SL, MVT::i32, Cast,
14461
- DAG.getConstant(EltIdx, SL, MVT::i32));
14462
- DCI.AddToWorklist(Elt.getNode());
14463
- SDValue Srl = DAG.getNode(ISD::SRL, SL, MVT::i32, Elt,
14464
- DAG.getConstant(LeftoverBitIdx, SL, MVT::i32));
14465
- DCI.AddToWorklist(Srl.getNode());
14417
+ SDValue Cast = DAG.getNode(ISD::BITCAST, SL, NewVT, Vec);
14418
+ DCI.AddToWorklist(Cast.getNode());
14466
14419
14467
- EVT VecEltAsIntVT = VecEltVT.changeTypeToInteger();
14468
- SDValue Trunc = DAG.getNode(ISD::TRUNCATE, SL, VecEltAsIntVT, Srl);
14469
- DCI.AddToWorklist(Trunc.getNode());
14420
+ SDValue Elt = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, SL, MVT::i32, Cast,
14421
+ DAG.getConstant(EltIdx, SL, MVT::i32));
14422
+ DCI.AddToWorklist(Elt.getNode());
14423
+ SDValue Srl = DAG.getNode(ISD::SRL, SL, MVT::i32, Elt,
14424
+ DAG.getConstant(LeftoverBitIdx, SL, MVT::i32));
14425
+ DCI.AddToWorklist(Srl.getNode());
14470
14426
14471
- if (VecEltVT == ResVT) {
14472
- return DAG.getNode(ISD::BITCAST , SL, VecEltVT, Trunc );
14473
- }
14427
+ EVT VecEltAsIntVT = VecEltVT.changeTypeToInteger();
14428
+ SDValue Trunc = DAG.getNode(ISD::TRUNCATE , SL, VecEltAsIntVT, Srl );
14429
+ DCI.AddToWorklist(Trunc.getNode());
14474
14430
14475
- assert( ResVT.isScalarInteger());
14476
- return DAG.getAnyExtOrTrunc(Trunc , SL, ResVT );
14431
+ if (VecEltVT == ResVT) {
14432
+ return DAG.getNode(ISD::BITCAST , SL, VecEltVT, Trunc );
14477
14433
}
14478
14434
14479
- return SDValue();
14435
+ assert(ResVT.isScalarInteger());
14436
+ return DAG.getAnyExtOrTrunc(Trunc, SL, ResVT);
14480
14437
}
14481
14438
14439
+ return SDValue();
14440
+ }
14441
+
14482
14442
SDValue
14483
14443
SITargetLowering::performInsertVectorEltCombine(SDNode *N,
14484
14444
DAGCombinerInfo &DCI) const {
0 commit comments