Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/include/llvm/CodeGen/LowLevelTypeUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 6 additions & 8 deletions llvm/include/llvm/CodeGen/TargetLowering.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
15 changes: 5 additions & 10 deletions llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3122,16 +3122,14 @@ 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);
const TargetLowering &TLI = getTargetLowering();

// 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;
}
Expand Down Expand Up @@ -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}}))
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/CodeGen/GlobalISel/CombinerHelperCasts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/GlobalISel/LoadStoreOpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ bool LoadStoreOpt::mergeStores(SmallVectorImpl<GStore *> &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)))
Expand Down
5 changes: 2 additions & 3 deletions llvm/lib/CodeGen/LowLevelTypeUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/TargetLoweringBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Loading