From 9247beb8f8af148325b352aef449e4f4475908b3 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Thu, 12 Dec 2024 23:34:51 -0800 Subject: [PATCH] [GISel] Remove unused DataLayout operand from getApproximateEVTForLLT --- llvm/include/llvm/CodeGen/LowLevelTypeUtils.h | 2 +- llvm/include/llvm/CodeGen/TargetLowering.h | 14 ++++++-------- llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp | 15 +++++---------- .../CodeGen/GlobalISel/CombinerHelperCasts.cpp | 4 ++-- llvm/lib/CodeGen/GlobalISel/LoadStoreOpt.cpp | 2 +- llvm/lib/CodeGen/LowLevelTypeUtils.cpp | 5 ++--- llvm/lib/CodeGen/TargetLoweringBase.cpp | 2 +- 7 files changed, 18 insertions(+), 26 deletions(-) diff --git a/llvm/include/llvm/CodeGen/LowLevelTypeUtils.h b/llvm/include/llvm/CodeGen/LowLevelTypeUtils.h index 7d99b7731767b..142e5cd4e7ad1 100644 --- a/llvm/include/llvm/CodeGen/LowLevelTypeUtils.h +++ b/llvm/include/llvm/CodeGen/LowLevelTypeUtils.h @@ -31,7 +31,7 @@ LLT getLLTForType(Type &Ty, const DataLayout &DL); /// Get a rough equivalent of an MVT for a given LLT. MVT can't distinguish /// pointers, so these will convert to a plain integer. MVT getMVTForLLT(LLT Ty); -EVT getApproximateEVTForLLT(LLT Ty, const DataLayout &DL, LLVMContext &Ctx); +EVT getApproximateEVTForLLT(LLT Ty, LLVMContext &Ctx); /// Get a rough equivalent of an LLT for a given MVT. LLT does not yet support /// scalarable vector types, and will assert if used. diff --git a/llvm/include/llvm/CodeGen/TargetLowering.h b/llvm/include/llvm/CodeGen/TargetLowering.h index aaab209bfa75d..3751aac4df8ea 100644 --- a/llvm/include/llvm/CodeGen/TargetLowering.h +++ b/llvm/include/llvm/CodeGen/TargetLowering.h @@ -2979,10 +2979,9 @@ class TargetLoweringBase { } virtual bool isTruncateFree(EVT FromVT, EVT ToVT) const { return false; } - virtual bool isTruncateFree(LLT FromTy, LLT ToTy, const DataLayout &DL, - LLVMContext &Ctx) const { - return isTruncateFree(getApproximateEVTForLLT(FromTy, DL, Ctx), - getApproximateEVTForLLT(ToTy, DL, Ctx)); + virtual bool isTruncateFree(LLT FromTy, LLT ToTy, LLVMContext &Ctx) const { + return isTruncateFree(getApproximateEVTForLLT(FromTy, Ctx), + getApproximateEVTForLLT(ToTy, Ctx)); } /// Return true if truncating the specific node Val to type VT2 is free. @@ -3065,10 +3064,9 @@ class TargetLoweringBase { } virtual bool isZExtFree(EVT FromTy, EVT ToTy) const { return false; } - virtual bool isZExtFree(LLT FromTy, LLT ToTy, const DataLayout &DL, - LLVMContext &Ctx) const { - return isZExtFree(getApproximateEVTForLLT(FromTy, DL, Ctx), - getApproximateEVTForLLT(ToTy, DL, Ctx)); + virtual bool isZExtFree(LLT FromTy, LLT ToTy, LLVMContext &Ctx) const { + return isZExtFree(getApproximateEVTForLLT(FromTy, Ctx), + getApproximateEVTForLLT(ToTy, Ctx)); } /// Return true if zero-extending the specific node Val to type VT2 is free diff --git a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp index a273799544652..bbeb748f770b5 100644 --- a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp +++ b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp @@ -3122,7 +3122,6 @@ bool CombinerHelper::matchHoistLogicOpWithSameOpcodeHands( case TargetOpcode::G_TRUNC: { // Match: logic (trunc X), (trunc Y) -> trunc (logic X, Y) const MachineFunction *MF = MI.getMF(); - const DataLayout &DL = MF->getDataLayout(); LLVMContext &Ctx = MF->getFunction().getContext(); LLT DstTy = MRI.getType(Dst); @@ -3130,8 +3129,7 @@ bool CombinerHelper::matchHoistLogicOpWithSameOpcodeHands( // Be extra careful sinking truncate. If it's free, there's no benefit in // widening a binop. - if (TLI.isZExtFree(DstTy, XTy, DL, Ctx) && - TLI.isTruncateFree(XTy, DstTy, DL, Ctx)) + if (TLI.isZExtFree(DstTy, XTy, Ctx) && TLI.isTruncateFree(XTy, DstTy, Ctx)) return false; break; } @@ -5072,9 +5070,8 @@ bool CombinerHelper::matchNarrowBinopFeedingAnd( auto &MF = *MI.getMF(); const auto &TLI = getTargetLowering(); LLVMContext &Ctx = MF.getFunction().getContext(); - auto &DL = MF.getDataLayout(); - if (!TLI.isTruncateFree(WideTy, NarrowTy, DL, Ctx) || - !TLI.isZExtFree(NarrowTy, WideTy, DL, Ctx)) + if (!TLI.isTruncateFree(WideTy, NarrowTy, Ctx) || + !TLI.isZExtFree(NarrowTy, WideTy, Ctx)) return false; if (!isLegalOrBeforeLegalizer({TargetOpcode::G_TRUNC, {NarrowTy, WideTy}}) || !isLegalOrBeforeLegalizer({TargetOpcode::G_ZEXT, {WideTy, NarrowTy}})) @@ -5378,8 +5375,7 @@ bool CombinerHelper::matchUDivByConst(MachineInstr &MI) { AttributeList Attr = MF.getFunction().getAttributes(); const auto &TLI = getTargetLowering(); LLVMContext &Ctx = MF.getFunction().getContext(); - auto &DL = MF.getDataLayout(); - if (TLI.isIntDivCheap(getApproximateEVTForLLT(DstTy, DL, Ctx), Attr)) + if (TLI.isIntDivCheap(getApproximateEVTForLLT(DstTy, Ctx), Attr)) return false; // Don't do this for minsize because the instruction sequence is usually @@ -5428,8 +5424,7 @@ bool CombinerHelper::matchSDivByConst(MachineInstr &MI) { AttributeList Attr = MF.getFunction().getAttributes(); const auto &TLI = getTargetLowering(); LLVMContext &Ctx = MF.getFunction().getContext(); - auto &DL = MF.getDataLayout(); - if (TLI.isIntDivCheap(getApproximateEVTForLLT(DstTy, DL, Ctx), Attr)) + if (TLI.isIntDivCheap(getApproximateEVTForLLT(DstTy, Ctx), Attr)) return false; // Don't do this for minsize because the instruction sequence is usually diff --git a/llvm/lib/CodeGen/GlobalISel/CombinerHelperCasts.cpp b/llvm/lib/CodeGen/GlobalISel/CombinerHelperCasts.cpp index 30557e6a2304e..09815e85ea859 100644 --- a/llvm/lib/CodeGen/GlobalISel/CombinerHelperCasts.cpp +++ b/llvm/lib/CodeGen/GlobalISel/CombinerHelperCasts.cpp @@ -170,9 +170,9 @@ bool CombinerHelper::isCastFree(unsigned Opcode, LLT ToTy, LLT FromTy) const { switch (Opcode) { case TargetOpcode::G_ANYEXT: case TargetOpcode::G_ZEXT: - return TLI.isZExtFree(FromTy, ToTy, DL, Ctx); + return TLI.isZExtFree(FromTy, ToTy, Ctx); case TargetOpcode::G_TRUNC: - return TLI.isTruncateFree(FromTy, ToTy, DL, Ctx); + return TLI.isTruncateFree(FromTy, ToTy, Ctx); default: return false; } diff --git a/llvm/lib/CodeGen/GlobalISel/LoadStoreOpt.cpp b/llvm/lib/CodeGen/GlobalISel/LoadStoreOpt.cpp index e411e73dbe734..08d30db0ca898 100644 --- a/llvm/lib/CodeGen/GlobalISel/LoadStoreOpt.cpp +++ b/llvm/lib/CodeGen/GlobalISel/LoadStoreOpt.cpp @@ -327,7 +327,7 @@ bool LoadStoreOpt::mergeStores(SmallVectorImpl &StoresToMerge) { for (MergeSizeBits = MaxSizeBits; MergeSizeBits > 1; MergeSizeBits /= 2) { LLT StoreTy = LLT::scalar(MergeSizeBits); EVT StoreEVT = - getApproximateEVTForLLT(StoreTy, DL, MF->getFunction().getContext()); + getApproximateEVTForLLT(StoreTy, MF->getFunction().getContext()); if (LegalSizes.size() > MergeSizeBits && LegalSizes[MergeSizeBits] && TLI->canMergeStoresTo(AS, StoreEVT, *MF) && (TLI->isTypeLegal(StoreEVT))) diff --git a/llvm/lib/CodeGen/LowLevelTypeUtils.cpp b/llvm/lib/CodeGen/LowLevelTypeUtils.cpp index 1602cd99c383c..936c9fbb2fff0 100644 --- a/llvm/lib/CodeGen/LowLevelTypeUtils.cpp +++ b/llvm/lib/CodeGen/LowLevelTypeUtils.cpp @@ -54,10 +54,9 @@ MVT llvm::getMVTForLLT(LLT Ty) { Ty.getElementCount()); } -EVT llvm::getApproximateEVTForLLT(LLT Ty, const DataLayout &DL, - LLVMContext &Ctx) { +EVT llvm::getApproximateEVTForLLT(LLT Ty, LLVMContext &Ctx) { if (Ty.isVector()) { - EVT EltVT = getApproximateEVTForLLT(Ty.getElementType(), DL, Ctx); + EVT EltVT = getApproximateEVTForLLT(Ty.getElementType(), Ctx); return EVT::getVectorVT(Ctx, EltVT, Ty.getElementCount()); } diff --git a/llvm/lib/CodeGen/TargetLoweringBase.cpp b/llvm/lib/CodeGen/TargetLoweringBase.cpp index 9dc2701654b8b..3b0e9c7526fd0 100644 --- a/llvm/lib/CodeGen/TargetLoweringBase.cpp +++ b/llvm/lib/CodeGen/TargetLoweringBase.cpp @@ -1750,7 +1750,7 @@ bool TargetLoweringBase::allowsMemoryAccess(LLVMContext &Context, const DataLayout &DL, LLT Ty, const MachineMemOperand &MMO, unsigned *Fast) const { - EVT VT = getApproximateEVTForLLT(Ty, DL, Context); + EVT VT = getApproximateEVTForLLT(Ty, Context); return allowsMemoryAccess(Context, DL, VT, MMO.getAddrSpace(), MMO.getAlign(), MMO.getFlags(), Fast); }