@@ -598,12 +598,11 @@ bool TargetLowering::ShrinkDemandedOp(SDValue Op, unsigned BitWidth,
598
598
599
599
// Search for the smallest integer type with free casts to and from
600
600
// Op's type. For expedience, just check power-of-2 integer types.
601
- const TargetLowering &TLI = DAG.getTargetLoweringInfo ();
602
601
unsigned DemandedSize = DemandedBits.getActiveBits ();
603
602
for (unsigned SmallVTBits = llvm::bit_ceil (DemandedSize);
604
603
SmallVTBits < BitWidth; SmallVTBits = NextPowerOf2 (SmallVTBits)) {
605
604
EVT SmallVT = EVT::getIntegerVT (*DAG.getContext (), SmallVTBits);
606
- if (TLI. isTruncateFree (VT, SmallVT) && TLI. isZExtFree (SmallVT, VT)) {
605
+ if (isTruncateFree (VT, SmallVT) && isZExtFree (SmallVT, VT)) {
607
606
// We found a type with free casts.
608
607
SDValue X = DAG.getNode (
609
608
Op.getOpcode (), dl, SmallVT,
@@ -1622,9 +1621,8 @@ bool TargetLowering::SimplifyDemandedBits(
1622
1621
APInt Ones = APInt::getAllOnes (BitWidth);
1623
1622
Ones = Op0Opcode == ISD::SHL ? Ones.shl (ShiftAmt)
1624
1623
: Ones.lshr (ShiftAmt);
1625
- const TargetLowering &TLI = TLO.DAG .getTargetLoweringInfo ();
1626
1624
if ((DemandedBits & C->getAPIntValue ()) == (DemandedBits & Ones) &&
1627
- TLI. isDesirableToCommuteXorWithShift (Op.getNode ())) {
1625
+ isDesirableToCommuteXorWithShift (Op.getNode ())) {
1628
1626
// If the xor constant is a demanded mask, do a 'not' before the
1629
1627
// shift:
1630
1628
// xor (X << ShiftC), XorC --> (not X) << ShiftC
@@ -3065,8 +3063,7 @@ bool TargetLowering::SimplifyDemandedVectorElts(
3065
3063
3066
3064
KnownUndef = KnownZero = APInt::getZero (NumElts);
3067
3065
3068
- const TargetLowering &TLI = TLO.DAG .getTargetLoweringInfo ();
3069
- if (!TLI.shouldSimplifyDemandedVectorElts (Op, TLO))
3066
+ if (!shouldSimplifyDemandedVectorElts (Op, TLO))
3070
3067
return false ;
3071
3068
3072
3069
// TODO: For now we assume we know nothing about scalable vectors.
@@ -4162,8 +4159,7 @@ SDValue TargetLowering::optimizeSetCCOfSignedTruncationCheck(
4162
4159
4163
4160
// We don't want to do this in every single case.
4164
4161
SelectionDAG &DAG = DCI.DAG ;
4165
- if (!DAG.getTargetLoweringInfo ().shouldTransformSignedTruncationCheck (
4166
- XVT, KeptBits))
4162
+ if (!shouldTransformSignedTruncationCheck (XVT, KeptBits))
4167
4163
return SDValue ();
4168
4164
4169
4165
// Unfold into: sext_inreg(%x) cond %x
@@ -4187,10 +4183,9 @@ SDValue TargetLowering::optimizeSetCCByHoistingAndByConstFromLogicalShift(
4187
4183
SDValue X, C, Y;
4188
4184
4189
4185
SelectionDAG &DAG = DCI.DAG ;
4190
- const TargetLowering &TLI = DAG.getTargetLoweringInfo ();
4191
4186
4192
4187
// Look for '(C l>>/<< Y)'.
4193
- auto Match = [&NewShiftOpcode, &X, &C, &Y, &TLI, &DAG ](SDValue V) {
4188
+ auto Match = [&NewShiftOpcode, &X, &C, &Y, &DAG, this ](SDValue V) {
4194
4189
// The shift should be one-use.
4195
4190
if (!V.hasOneUse ())
4196
4191
return false ;
@@ -4216,7 +4211,7 @@ SDValue TargetLowering::optimizeSetCCByHoistingAndByConstFromLogicalShift(
4216
4211
4217
4212
ConstantSDNode *XC =
4218
4213
isConstOrConstSplat (X, /* AllowUndefs=*/ true , /* AllowTruncation=*/ true );
4219
- return TLI. shouldProduceAndByConstByHoistingConstFromShiftsLHSOfAnd (
4214
+ return shouldProduceAndByConstByHoistingConstFromShiftsLHSOfAnd (
4220
4215
X, XC, CC, Y, OldShiftOpcode, NewShiftOpcode, DAG);
4221
4216
};
4222
4217
@@ -5114,7 +5109,6 @@ SDValue TargetLowering::SimplifySetCC(EVT VT, SDValue N0, SDValue N1,
5114
5109
// Back to non-vector simplifications.
5115
5110
// TODO: Can we do these for vector splats?
5116
5111
if (auto *N1C = dyn_cast<ConstantSDNode>(N1.getNode ())) {
5117
- const TargetLowering &TLI = DAG.getTargetLoweringInfo ();
5118
5112
const APInt &C1 = N1C->getAPIntValue ();
5119
5113
EVT ShValTy = N0.getValueType ();
5120
5114
@@ -5132,7 +5126,7 @@ SDValue TargetLowering::SimplifySetCC(EVT VT, SDValue N0, SDValue N1,
5132
5126
// Perform the xform if the AND RHS is a single bit.
5133
5127
unsigned ShCt = AndRHS->getAPIntValue ().logBase2 ();
5134
5128
if (AndRHS->getAPIntValue ().isPowerOf2 () &&
5135
- !TLI. shouldAvoidTransformToShift (ShValTy, ShCt)) {
5129
+ !shouldAvoidTransformToShift (ShValTy, ShCt)) {
5136
5130
return DAG.getNode (
5137
5131
ISD::TRUNCATE, dl, VT,
5138
5132
DAG.getNode (ISD::SRL, dl, ShValTy, N0,
@@ -5142,8 +5136,7 @@ SDValue TargetLowering::SimplifySetCC(EVT VT, SDValue N0, SDValue N1,
5142
5136
// (X & 8) == 8 --> (X & 8) >> 3
5143
5137
// Perform the xform if C1 is a single bit.
5144
5138
unsigned ShCt = C1.logBase2 ();
5145
- if (C1.isPowerOf2 () &&
5146
- !TLI.shouldAvoidTransformToShift (ShValTy, ShCt)) {
5139
+ if (C1.isPowerOf2 () && !shouldAvoidTransformToShift (ShValTy, ShCt)) {
5147
5140
return DAG.getNode (
5148
5141
ISD::TRUNCATE, dl, VT,
5149
5142
DAG.getNode (ISD::SRL, dl, ShValTy, N0,
@@ -5162,7 +5155,7 @@ SDValue TargetLowering::SimplifySetCC(EVT VT, SDValue N0, SDValue N1,
5162
5155
const APInt &AndRHSC = AndRHS->getAPIntValue ();
5163
5156
if (AndRHSC.isNegatedPowerOf2 () && C1.isSubsetOf (AndRHSC)) {
5164
5157
unsigned ShiftBits = AndRHSC.countr_zero ();
5165
- if (!TLI. shouldAvoidTransformToShift (ShValTy, ShiftBits)) {
5158
+ if (!shouldAvoidTransformToShift (ShValTy, ShiftBits)) {
5166
5159
SDValue Shift = DAG.getNode (
5167
5160
ISD::SRL, dl, ShValTy, N0.getOperand (0 ),
5168
5161
DAG.getShiftAmountConstant (ShiftBits, ShValTy, dl));
@@ -5191,7 +5184,7 @@ SDValue TargetLowering::SimplifySetCC(EVT VT, SDValue N0, SDValue N1,
5191
5184
NewC.lshrInPlace (ShiftBits);
5192
5185
if (ShiftBits && NewC.getSignificantBits () <= 64 &&
5193
5186
isLegalICmpImmediate (NewC.getSExtValue ()) &&
5194
- !TLI. shouldAvoidTransformToShift (ShValTy, ShiftBits)) {
5187
+ !shouldAvoidTransformToShift (ShValTy, ShiftBits)) {
5195
5188
SDValue Shift =
5196
5189
DAG.getNode (ISD::SRL, dl, ShValTy, N0,
5197
5190
DAG.getShiftAmountConstant (ShiftBits, ShValTy, dl));
@@ -6234,8 +6227,7 @@ SDValue TargetLowering::BuildSDIVPow2(SDNode *N, const APInt &Divisor,
6234
6227
SelectionDAG &DAG,
6235
6228
SmallVectorImpl<SDNode *> &Created) const {
6236
6229
AttributeList Attr = DAG.getMachineFunction ().getFunction ().getAttributes ();
6237
- const TargetLowering &TLI = DAG.getTargetLoweringInfo ();
6238
- if (TLI.isIntDivCheap (N->getValueType (0 ), Attr))
6230
+ if (isIntDivCheap (N->getValueType (0 ), Attr))
6239
6231
return SDValue (N, 0 ); // Lower SDIV as SDIV
6240
6232
return SDValue ();
6241
6233
}
@@ -6245,8 +6237,7 @@ TargetLowering::BuildSREMPow2(SDNode *N, const APInt &Divisor,
6245
6237
SelectionDAG &DAG,
6246
6238
SmallVectorImpl<SDNode *> &Created) const {
6247
6239
AttributeList Attr = DAG.getMachineFunction ().getFunction ().getAttributes ();
6248
- const TargetLowering &TLI = DAG.getTargetLoweringInfo ();
6249
- if (TLI.isIntDivCheap (N->getValueType (0 ), Attr))
6240
+ if (isIntDivCheap (N->getValueType (0 ), Attr))
6250
6241
return SDValue (N, 0 ); // Lower SREM as SREM
6251
6242
return SDValue ();
6252
6243
}
@@ -11746,35 +11737,34 @@ bool TargetLowering::LegalizeSetCCCondCode(SelectionDAG &DAG, EVT VT,
11746
11737
SDValue EVL, bool &NeedInvert,
11747
11738
const SDLoc &dl, SDValue &Chain,
11748
11739
bool IsSignaling) const {
11749
- const TargetLowering &TLI = DAG.getTargetLoweringInfo ();
11750
11740
MVT OpVT = LHS.getSimpleValueType ();
11751
11741
ISD::CondCode CCCode = cast<CondCodeSDNode>(CC)->get ();
11752
11742
NeedInvert = false ;
11753
11743
assert (!EVL == !Mask && " VP Mask and EVL must either both be set or unset" );
11754
11744
bool IsNonVP = !EVL;
11755
- switch (TLI. getCondCodeAction (CCCode, OpVT)) {
11745
+ switch (getCondCodeAction (CCCode, OpVT)) {
11756
11746
default :
11757
11747
llvm_unreachable (" Unknown condition code action!" );
11758
11748
case TargetLowering::Legal:
11759
11749
// Nothing to do.
11760
11750
break ;
11761
11751
case TargetLowering::Expand: {
11762
11752
ISD::CondCode InvCC = ISD::getSetCCSwappedOperands (CCCode);
11763
- if (TLI. isCondCodeLegalOrCustom (InvCC, OpVT)) {
11753
+ if (isCondCodeLegalOrCustom (InvCC, OpVT)) {
11764
11754
std::swap (LHS, RHS);
11765
11755
CC = DAG.getCondCode (InvCC);
11766
11756
return true ;
11767
11757
}
11768
11758
// Swapping operands didn't work. Try inverting the condition.
11769
11759
bool NeedSwap = false ;
11770
11760
InvCC = getSetCCInverse (CCCode, OpVT);
11771
- if (!TLI. isCondCodeLegalOrCustom (InvCC, OpVT)) {
11761
+ if (!isCondCodeLegalOrCustom (InvCC, OpVT)) {
11772
11762
// If inverting the condition is not enough, try swapping operands
11773
11763
// on top of it.
11774
11764
InvCC = ISD::getSetCCSwappedOperands (InvCC);
11775
11765
NeedSwap = true ;
11776
11766
}
11777
- if (TLI. isCondCodeLegalOrCustom (InvCC, OpVT)) {
11767
+ if (isCondCodeLegalOrCustom (InvCC, OpVT)) {
11778
11768
CC = DAG.getCondCode (InvCC);
11779
11769
NeedInvert = true ;
11780
11770
if (NeedSwap)
@@ -11788,18 +11778,18 @@ bool TargetLowering::LegalizeSetCCCondCode(SelectionDAG &DAG, EVT VT,
11788
11778
default :
11789
11779
llvm_unreachable (" Don't know how to expand this condition!" );
11790
11780
case ISD::SETUO:
11791
- if (TLI. isCondCodeLegal (ISD::SETUNE, OpVT)) {
11781
+ if (isCondCodeLegal (ISD::SETUNE, OpVT)) {
11792
11782
CC1 = ISD::SETUNE;
11793
11783
CC2 = ISD::SETUNE;
11794
11784
Opc = ISD::OR;
11795
11785
break ;
11796
11786
}
11797
- assert (TLI. isCondCodeLegal (ISD::SETOEQ, OpVT) &&
11787
+ assert (isCondCodeLegal (ISD::SETOEQ, OpVT) &&
11798
11788
" If SETUE is expanded, SETOEQ or SETUNE must be legal!" );
11799
11789
NeedInvert = true ;
11800
11790
[[fallthrough]];
11801
11791
case ISD::SETO:
11802
- assert (TLI. isCondCodeLegal (ISD::SETOEQ, OpVT) &&
11792
+ assert (isCondCodeLegal (ISD::SETOEQ, OpVT) &&
11803
11793
" If SETO is expanded, SETOEQ must be legal!" );
11804
11794
CC1 = ISD::SETOEQ;
11805
11795
CC2 = ISD::SETOEQ;
@@ -11812,9 +11802,8 @@ bool TargetLowering::LegalizeSetCCCondCode(SelectionDAG &DAG, EVT VT,
11812
11802
// of SETOGT/SETOLT to be legal, the other can be emulated by swapping
11813
11803
// the operands.
11814
11804
CC2 = ((unsigned )CCCode & 0x8U ) ? ISD::SETUO : ISD::SETO;
11815
- if (!TLI.isCondCodeLegal (CC2, OpVT) &&
11816
- (TLI.isCondCodeLegal (ISD::SETOGT, OpVT) ||
11817
- TLI.isCondCodeLegal (ISD::SETOLT, OpVT))) {
11805
+ if (!isCondCodeLegal (CC2, OpVT) && (isCondCodeLegal (ISD::SETOGT, OpVT) ||
11806
+ isCondCodeLegal (ISD::SETOLT, OpVT))) {
11818
11807
CC1 = ISD::SETOGT;
11819
11808
CC2 = ISD::SETOLT;
11820
11809
Opc = ISD::OR;
0 commit comments