@@ -585,8 +585,7 @@ void SelectionDAGLegalize::LegalizeStoreOps(SDNode *Node) {
585
585
DAG.getMemBasePlusOffset (Ptr, TypeSize::getFixed (IncrementSize), dl);
586
586
Hi = DAG.getNode (
587
587
ISD::SRL, dl, Value.getValueType (), Value,
588
- DAG.getConstant (RoundWidth, dl,
589
- TLI.getShiftAmountTy (Value.getValueType (), DL)));
588
+ DAG.getShiftAmountConstant (RoundWidth, Value.getValueType (), dl));
590
589
Hi = DAG.getTruncStore (Chain, dl, Hi, Ptr,
591
590
ST->getPointerInfo ().getWithOffset (IncrementSize),
592
591
ExtraVT, ST->getBaseAlign (), MMOFlags, AAInfo);
@@ -596,8 +595,7 @@ void SelectionDAGLegalize::LegalizeStoreOps(SDNode *Node) {
596
595
// Store the top RoundWidth bits.
597
596
Hi = DAG.getNode (
598
597
ISD::SRL, dl, Value.getValueType (), Value,
599
- DAG.getConstant (ExtraWidth, dl,
600
- TLI.getShiftAmountTy (Value.getValueType (), DL)));
598
+ DAG.getShiftAmountConstant (ExtraWidth, Value.getValueType (), dl));
601
599
Hi = DAG.getTruncStore (Chain, dl, Hi, Ptr, ST->getPointerInfo (), RoundVT,
602
600
ST->getBaseAlign (), MMOFlags, AAInfo);
603
601
@@ -816,8 +814,7 @@ void SelectionDAGLegalize::LegalizeLoadOps(SDNode *Node) {
816
814
// Move the top bits to the right place.
817
815
Hi = DAG.getNode (
818
816
ISD::SHL, dl, Hi.getValueType (), Hi,
819
- DAG.getConstant (RoundWidth, dl,
820
- TLI.getShiftAmountTy (Hi.getValueType (), DL)));
817
+ DAG.getShiftAmountConstant (RoundWidth, Hi.getValueType (), dl));
821
818
822
819
// Join the hi and lo parts.
823
820
Value = DAG.getNode (ISD::OR, dl, Node->getValueType (0 ), Lo, Hi);
@@ -845,8 +842,7 @@ void SelectionDAGLegalize::LegalizeLoadOps(SDNode *Node) {
845
842
// Move the top bits to the right place.
846
843
Hi = DAG.getNode (
847
844
ISD::SHL, dl, Hi.getValueType (), Hi,
848
- DAG.getConstant (ExtraWidth, dl,
849
- TLI.getShiftAmountTy (Hi.getValueType (), DL)));
845
+ DAG.getShiftAmountConstant (ExtraWidth, Hi.getValueType (), dl));
850
846
851
847
// Join the hi and lo parts.
852
848
Value = DAG.getNode (ISD::OR, dl, Node->getValueType (0 ), Lo, Hi);
@@ -2767,8 +2763,7 @@ SDValue SelectionDAGLegalize::ExpandLegalINT_TO_FP(SDNode *Node,
2767
2763
SDValue SignBitTest = DAG.getSetCC (
2768
2764
dl, SetCCVT, Op0, DAG.getConstant (0 , dl, SrcVT), ISD::SETLT);
2769
2765
2770
- EVT ShiftVT = TLI.getShiftAmountTy (SrcVT, DAG.getDataLayout ());
2771
- SDValue ShiftConst = DAG.getConstant (1 , dl, ShiftVT);
2766
+ SDValue ShiftConst = DAG.getShiftAmountConstant (1 , SrcVT, dl);
2772
2767
SDValue Shr = DAG.getNode (ISD::SRL, dl, SrcVT, Op0, ShiftConst);
2773
2768
SDValue AndConst = DAG.getConstant (1 , dl, SrcVT);
2774
2769
SDValue And = DAG.getNode (ISD::AND, dl, SrcVT, Op0, AndConst);
@@ -3350,10 +3345,8 @@ bool SelectionDAGLegalize::ExpandNode(SDNode *Node) {
3350
3345
} else {
3351
3346
Op = DAG.getAnyExtOrTrunc (Op, dl, MVT::i32 );
3352
3347
}
3353
- Op = DAG.getNode (
3354
- ISD::SHL, dl, MVT::i32 , Op,
3355
- DAG.getConstant (16 , dl,
3356
- TLI.getShiftAmountTy (MVT::i32 , DAG.getDataLayout ())));
3348
+ Op = DAG.getNode (ISD::SHL, dl, MVT::i32 , Op,
3349
+ DAG.getShiftAmountConstant (16 , MVT::i32 , dl));
3357
3350
Op = DAG.getNode (ISD::BITCAST, dl, MVT::f32 , Op);
3358
3351
// Add fp_extend in case the output is bigger than f32.
3359
3352
if (Node->getValueType (0 ) != MVT::f32 )
@@ -3370,10 +3363,9 @@ bool SelectionDAGLegalize::ExpandNode(SDNode *Node) {
3370
3363
if (!DAG.isKnownNeverSNaN (Op)) {
3371
3364
Op = DAG.getNode (ISD::FCANONICALIZE, dl, MVT::f32 , Op, Node->getFlags ());
3372
3365
}
3373
- Op = DAG.getNode (
3374
- ISD::SRL, dl, MVT::i32 , DAG.getNode (ISD::BITCAST, dl, MVT::i32 , Op),
3375
- DAG.getConstant (16 , dl,
3376
- TLI.getShiftAmountTy (MVT::i32 , DAG.getDataLayout ())));
3366
+ Op = DAG.getNode (ISD::SRL, dl, MVT::i32 ,
3367
+ DAG.getNode (ISD::BITCAST, dl, MVT::i32 , Op),
3368
+ DAG.getShiftAmountConstant (16 , MVT::i32 , dl));
3377
3369
// The result of this node can be bf16 or an integer type in case bf16 is
3378
3370
// not supported on the target and was softened to i16 for storage.
3379
3371
if (Node->getValueType (0 ) == MVT::bf16 ) {
@@ -3431,13 +3423,11 @@ bool SelectionDAGLegalize::ExpandNode(SDNode *Node) {
3431
3423
3432
3424
// NOTE: we could fall back on load/store here too for targets without
3433
3425
// SRA. However, it is doubtful that any exist.
3434
- EVT ShiftAmountTy = TLI.getShiftAmountTy (VT, DAG.getDataLayout ());
3435
3426
unsigned BitsDiff = VT.getScalarSizeInBits () -
3436
3427
ExtraVT.getScalarSizeInBits ();
3437
- SDValue ShiftCst = DAG.getConstant (BitsDiff, dl, ShiftAmountTy);
3438
- Tmp1 = DAG.getNode (ISD::SHL, dl, Node->getValueType (0 ),
3439
- Node->getOperand (0 ), ShiftCst);
3440
- Tmp1 = DAG.getNode (ISD::SRA, dl, Node->getValueType (0 ), Tmp1, ShiftCst);
3428
+ SDValue ShiftCst = DAG.getShiftAmountConstant (BitsDiff, VT, dl);
3429
+ Tmp1 = DAG.getNode (ISD::SHL, dl, VT, Node->getOperand (0 ), ShiftCst);
3430
+ Tmp1 = DAG.getNode (ISD::SRA, dl, VT, Tmp1, ShiftCst);
3441
3431
Results.push_back (Tmp1);
3442
3432
break ;
3443
3433
}
@@ -3666,11 +3656,9 @@ bool SelectionDAGLegalize::ExpandNode(SDNode *Node) {
3666
3656
EVT OpTy = Node->getOperand (0 ).getValueType ();
3667
3657
if (Node->getConstantOperandVal (1 )) {
3668
3658
// 1 -> Hi
3669
- Tmp1 = DAG.getNode (ISD::SRL, dl, OpTy, Node->getOperand (0 ),
3670
- DAG.getConstant (OpTy.getSizeInBits () / 2 , dl,
3671
- TLI.getShiftAmountTy (
3672
- Node->getOperand (0 ).getValueType (),
3673
- DAG.getDataLayout ())));
3659
+ Tmp1 = DAG.getNode (
3660
+ ISD::SRL, dl, OpTy, Node->getOperand (0 ),
3661
+ DAG.getShiftAmountConstant (OpTy.getSizeInBits () / 2 , OpTy, dl));
3674
3662
Tmp1 = DAG.getNode (ISD::TRUNCATE, dl, Node->getValueType (0 ), Tmp1);
3675
3663
} else {
3676
3664
// 0 -> Lo
@@ -3950,9 +3938,8 @@ bool SelectionDAGLegalize::ExpandNode(SDNode *Node) {
3950
3938
for (unsigned i = 0 ; i < 2 ; ++i) {
3951
3939
SDValue Lo = DAG.getNode (ISD::ZERO_EXTEND, dl, VT, Halves[2 * i]);
3952
3940
SDValue Hi = DAG.getNode (ISD::ANY_EXTEND, dl, VT, Halves[2 * i + 1 ]);
3953
- SDValue Shift = DAG.getConstant (
3954
- HalfType.getScalarSizeInBits (), dl,
3955
- TLI.getShiftAmountTy (HalfType, DAG.getDataLayout ()));
3941
+ SDValue Shift =
3942
+ DAG.getShiftAmountConstant (HalfType.getScalarSizeInBits (), VT, dl);
3956
3943
Hi = DAG.getNode (ISD::SHL, dl, VT, Hi, Shift);
3957
3944
Results.push_back (DAG.getNode (ISD::OR, dl, VT, Lo, Hi));
3958
3945
}
@@ -3999,8 +3986,7 @@ bool SelectionDAGLegalize::ExpandNode(SDNode *Node) {
3999
3986
Lo = DAG.getNode (ISD::ZERO_EXTEND, dl, VT, Lo);
4000
3987
Hi = DAG.getNode (ISD::ANY_EXTEND, dl, VT, Hi);
4001
3988
SDValue Shift =
4002
- DAG.getConstant (HalfType.getSizeInBits (), dl,
4003
- TLI.getShiftAmountTy (HalfType, DAG.getDataLayout ()));
3989
+ DAG.getShiftAmountConstant (HalfType.getSizeInBits (), VT, dl);
4004
3990
Hi = DAG.getNode (ISD::SHL, dl, VT, Hi, Shift);
4005
3991
Results.push_back (DAG.getNode (ISD::OR, dl, VT, Lo, Hi));
4006
3992
}
@@ -4130,8 +4116,7 @@ bool SelectionDAGLegalize::ExpandNode(SDNode *Node) {
4130
4116
Tmp2 = DAG.getNode (ISD::ANY_EXTEND, dl, PairTy, Node->getOperand (1 ));
4131
4117
Tmp2 = DAG.getNode (
4132
4118
ISD::SHL, dl, PairTy, Tmp2,
4133
- DAG.getConstant (PairTy.getSizeInBits () / 2 , dl,
4134
- TLI.getShiftAmountTy (PairTy, DAG.getDataLayout ())));
4119
+ DAG.getShiftAmountConstant (PairTy.getSizeInBits () / 2 , PairTy, dl));
4135
4120
Results.push_back (DAG.getNode (ISD::OR, dl, PairTy, Tmp1, Tmp2));
4136
4121
break ;
4137
4122
}
@@ -5368,10 +5353,8 @@ void SelectionDAGLegalize::PromoteNode(SDNode *Node) {
5368
5353
unsigned DiffBits = NVT.getSizeInBits () - OVT.getSizeInBits ();
5369
5354
Tmp1 = DAG.getNode (ISD::ZERO_EXTEND, dl, NVT, Node->getOperand (0 ));
5370
5355
Tmp1 = DAG.getNode (Node->getOpcode (), dl, NVT, Tmp1);
5371
- Tmp1 = DAG.getNode (
5372
- ISD::SRL, dl, NVT, Tmp1,
5373
- DAG.getConstant (DiffBits, dl,
5374
- TLI.getShiftAmountTy (NVT, DAG.getDataLayout ())));
5356
+ Tmp1 = DAG.getNode (ISD::SRL, dl, NVT, Tmp1,
5357
+ DAG.getShiftAmountConstant (DiffBits, NVT, dl));
5375
5358
5376
5359
Results.push_back (DAG.getNode (ISD::TRUNCATE, dl, OVT, Tmp1));
5377
5360
break ;
@@ -5483,11 +5466,9 @@ void SelectionDAGLegalize::PromoteNode(SDNode *Node) {
5483
5466
Tmp2 = DAG.getNode (ExtOp, dl, NVT, Node->getOperand (1 ));
5484
5467
Tmp1 = DAG.getNode (ISD::MUL, dl, NVT, Tmp1, Tmp2);
5485
5468
5486
- auto &DL = DAG.getDataLayout ();
5487
5469
unsigned OriginalSize = OVT.getScalarSizeInBits ();
5488
- Tmp2 = DAG.getNode (
5489
- ISD::SRL, dl, NVT, Tmp1,
5490
- DAG.getConstant (OriginalSize, dl, TLI.getScalarShiftAmountTy (DL, NVT)));
5470
+ Tmp2 = DAG.getNode (ISD::SRL, dl, NVT, Tmp1,
5471
+ DAG.getShiftAmountConstant (OriginalSize, NVT, dl));
5491
5472
Results.push_back (DAG.getNode (ISD::TRUNCATE, dl, OVT, Tmp1));
5492
5473
Results.push_back (DAG.getNode (ISD::TRUNCATE, dl, OVT, Tmp2));
5493
5474
break ;
0 commit comments