Skip to content

Commit 0d9fc17

Browse files
authored
[GISel] Remove unused DataLayout operand from getApproximateEVTForLLT (#119833)
1 parent 939c94b commit 0d9fc17

File tree

7 files changed

+18
-26
lines changed

7 files changed

+18
-26
lines changed

llvm/include/llvm/CodeGen/LowLevelTypeUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ LLT getLLTForType(Type &Ty, const DataLayout &DL);
3131
/// Get a rough equivalent of an MVT for a given LLT. MVT can't distinguish
3232
/// pointers, so these will convert to a plain integer.
3333
MVT getMVTForLLT(LLT Ty);
34-
EVT getApproximateEVTForLLT(LLT Ty, const DataLayout &DL, LLVMContext &Ctx);
34+
EVT getApproximateEVTForLLT(LLT Ty, LLVMContext &Ctx);
3535

3636
/// Get a rough equivalent of an LLT for a given MVT. LLT does not yet support
3737
/// scalarable vector types, and will assert if used.

llvm/include/llvm/CodeGen/TargetLowering.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2979,10 +2979,9 @@ class TargetLoweringBase {
29792979
}
29802980

29812981
virtual bool isTruncateFree(EVT FromVT, EVT ToVT) const { return false; }
2982-
virtual bool isTruncateFree(LLT FromTy, LLT ToTy, const DataLayout &DL,
2983-
LLVMContext &Ctx) const {
2984-
return isTruncateFree(getApproximateEVTForLLT(FromTy, DL, Ctx),
2985-
getApproximateEVTForLLT(ToTy, DL, Ctx));
2982+
virtual bool isTruncateFree(LLT FromTy, LLT ToTy, LLVMContext &Ctx) const {
2983+
return isTruncateFree(getApproximateEVTForLLT(FromTy, Ctx),
2984+
getApproximateEVTForLLT(ToTy, Ctx));
29862985
}
29872986

29882987
/// Return true if truncating the specific node Val to type VT2 is free.
@@ -3065,10 +3064,9 @@ class TargetLoweringBase {
30653064
}
30663065

30673066
virtual bool isZExtFree(EVT FromTy, EVT ToTy) const { return false; }
3068-
virtual bool isZExtFree(LLT FromTy, LLT ToTy, const DataLayout &DL,
3069-
LLVMContext &Ctx) const {
3070-
return isZExtFree(getApproximateEVTForLLT(FromTy, DL, Ctx),
3071-
getApproximateEVTForLLT(ToTy, DL, Ctx));
3067+
virtual bool isZExtFree(LLT FromTy, LLT ToTy, LLVMContext &Ctx) const {
3068+
return isZExtFree(getApproximateEVTForLLT(FromTy, Ctx),
3069+
getApproximateEVTForLLT(ToTy, Ctx));
30723070
}
30733071

30743072
/// Return true if zero-extending the specific node Val to type VT2 is free

llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3124,16 +3124,14 @@ bool CombinerHelper::matchHoistLogicOpWithSameOpcodeHands(
31243124
case TargetOpcode::G_TRUNC: {
31253125
// Match: logic (trunc X), (trunc Y) -> trunc (logic X, Y)
31263126
const MachineFunction *MF = MI.getMF();
3127-
const DataLayout &DL = MF->getDataLayout();
31283127
LLVMContext &Ctx = MF->getFunction().getContext();
31293128

31303129
LLT DstTy = MRI.getType(Dst);
31313130
const TargetLowering &TLI = getTargetLowering();
31323131

31333132
// Be extra careful sinking truncate. If it's free, there's no benefit in
31343133
// widening a binop.
3135-
if (TLI.isZExtFree(DstTy, XTy, DL, Ctx) &&
3136-
TLI.isTruncateFree(XTy, DstTy, DL, Ctx))
3134+
if (TLI.isZExtFree(DstTy, XTy, Ctx) && TLI.isTruncateFree(XTy, DstTy, Ctx))
31373135
return false;
31383136
break;
31393137
}
@@ -5074,9 +5072,8 @@ bool CombinerHelper::matchNarrowBinopFeedingAnd(
50745072
auto &MF = *MI.getMF();
50755073
const auto &TLI = getTargetLowering();
50765074
LLVMContext &Ctx = MF.getFunction().getContext();
5077-
auto &DL = MF.getDataLayout();
5078-
if (!TLI.isTruncateFree(WideTy, NarrowTy, DL, Ctx) ||
5079-
!TLI.isZExtFree(NarrowTy, WideTy, DL, Ctx))
5075+
if (!TLI.isTruncateFree(WideTy, NarrowTy, Ctx) ||
5076+
!TLI.isZExtFree(NarrowTy, WideTy, Ctx))
50805077
return false;
50815078
if (!isLegalOrBeforeLegalizer({TargetOpcode::G_TRUNC, {NarrowTy, WideTy}}) ||
50825079
!isLegalOrBeforeLegalizer({TargetOpcode::G_ZEXT, {WideTy, NarrowTy}}))
@@ -5380,8 +5377,7 @@ bool CombinerHelper::matchUDivByConst(MachineInstr &MI) {
53805377
AttributeList Attr = MF.getFunction().getAttributes();
53815378
const auto &TLI = getTargetLowering();
53825379
LLVMContext &Ctx = MF.getFunction().getContext();
5383-
auto &DL = MF.getDataLayout();
5384-
if (TLI.isIntDivCheap(getApproximateEVTForLLT(DstTy, DL, Ctx), Attr))
5380+
if (TLI.isIntDivCheap(getApproximateEVTForLLT(DstTy, Ctx), Attr))
53855381
return false;
53865382

53875383
// Don't do this for minsize because the instruction sequence is usually
@@ -5430,8 +5426,7 @@ bool CombinerHelper::matchSDivByConst(MachineInstr &MI) {
54305426
AttributeList Attr = MF.getFunction().getAttributes();
54315427
const auto &TLI = getTargetLowering();
54325428
LLVMContext &Ctx = MF.getFunction().getContext();
5433-
auto &DL = MF.getDataLayout();
5434-
if (TLI.isIntDivCheap(getApproximateEVTForLLT(DstTy, DL, Ctx), Attr))
5429+
if (TLI.isIntDivCheap(getApproximateEVTForLLT(DstTy, Ctx), Attr))
54355430
return false;
54365431

54375432
// Don't do this for minsize because the instruction sequence is usually

llvm/lib/CodeGen/GlobalISel/CombinerHelperCasts.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,9 @@ bool CombinerHelper::isCastFree(unsigned Opcode, LLT ToTy, LLT FromTy) const {
170170
switch (Opcode) {
171171
case TargetOpcode::G_ANYEXT:
172172
case TargetOpcode::G_ZEXT:
173-
return TLI.isZExtFree(FromTy, ToTy, DL, Ctx);
173+
return TLI.isZExtFree(FromTy, ToTy, Ctx);
174174
case TargetOpcode::G_TRUNC:
175-
return TLI.isTruncateFree(FromTy, ToTy, DL, Ctx);
175+
return TLI.isTruncateFree(FromTy, ToTy, Ctx);
176176
default:
177177
return false;
178178
}

llvm/lib/CodeGen/GlobalISel/LoadStoreOpt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ bool LoadStoreOpt::mergeStores(SmallVectorImpl<GStore *> &StoresToMerge) {
327327
for (MergeSizeBits = MaxSizeBits; MergeSizeBits > 1; MergeSizeBits /= 2) {
328328
LLT StoreTy = LLT::scalar(MergeSizeBits);
329329
EVT StoreEVT =
330-
getApproximateEVTForLLT(StoreTy, DL, MF->getFunction().getContext());
330+
getApproximateEVTForLLT(StoreTy, MF->getFunction().getContext());
331331
if (LegalSizes.size() > MergeSizeBits && LegalSizes[MergeSizeBits] &&
332332
TLI->canMergeStoresTo(AS, StoreEVT, *MF) &&
333333
(TLI->isTypeLegal(StoreEVT)))

llvm/lib/CodeGen/LowLevelTypeUtils.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,9 @@ MVT llvm::getMVTForLLT(LLT Ty) {
5454
Ty.getElementCount());
5555
}
5656

57-
EVT llvm::getApproximateEVTForLLT(LLT Ty, const DataLayout &DL,
58-
LLVMContext &Ctx) {
57+
EVT llvm::getApproximateEVTForLLT(LLT Ty, LLVMContext &Ctx) {
5958
if (Ty.isVector()) {
60-
EVT EltVT = getApproximateEVTForLLT(Ty.getElementType(), DL, Ctx);
59+
EVT EltVT = getApproximateEVTForLLT(Ty.getElementType(), Ctx);
6160
return EVT::getVectorVT(Ctx, EltVT, Ty.getElementCount());
6261
}
6362

llvm/lib/CodeGen/TargetLoweringBase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1750,7 +1750,7 @@ bool TargetLoweringBase::allowsMemoryAccess(LLVMContext &Context,
17501750
const DataLayout &DL, LLT Ty,
17511751
const MachineMemOperand &MMO,
17521752
unsigned *Fast) const {
1753-
EVT VT = getApproximateEVTForLLT(Ty, DL, Context);
1753+
EVT VT = getApproximateEVTForLLT(Ty, Context);
17541754
return allowsMemoryAccess(Context, DL, VT, MMO.getAddrSpace(), MMO.getAlign(),
17551755
MMO.getFlags(), Fast);
17561756
}

0 commit comments

Comments
 (0)