diff options
author | Roman Lebedev <lebedev.ri@gmail.com> | 2022-12-31 02:07:50 +0300 |
---|---|---|
committer | Roman Lebedev <lebedev.ri@gmail.com> | 2022-12-31 02:07:50 +0300 |
commit | 603e8490729e477680f0bc8284e136ceeb66e7f4 (patch) | |
tree | b7ccd8347f4631a7537b4c8b42c0f0d886b3fed7 /llvm/lib/CodeGen/TargetLoweringBase.cpp | |
parent | e4d25a9c234b1501bc4ac01f4e40d75f6ebee172 (diff) | |
download | llvm-603e8490729e477680f0bc8284e136ceeb66e7f4.zip llvm-603e8490729e477680f0bc8284e136ceeb66e7f4.tar.gz llvm-603e8490729e477680f0bc8284e136ceeb66e7f4.tar.bz2 |
[NFC][TLI] Move `isLoadBitCastBeneficial()` implementation into source file
... so any change to it does not cause 700 source files to be recompiled.
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringBase.cpp')
-rw-r--r-- | llvm/lib/CodeGen/TargetLoweringBase.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringBase.cpp b/llvm/lib/CodeGen/TargetLoweringBase.cpp index fba60c8..37eb96e 100644 --- a/llvm/lib/CodeGen/TargetLoweringBase.cpp +++ b/llvm/lib/CodeGen/TargetLoweringBase.cpp @@ -2214,6 +2214,28 @@ int TargetLoweringBase::getDivRefinementSteps(EVT VT, return getOpRefinementSteps(false, VT, getRecipEstimateForFunc(MF)); } +bool TargetLoweringBase::isLoadBitCastBeneficial( + EVT LoadVT, EVT BitcastVT, const SelectionDAG &DAG, + const MachineMemOperand &MMO) const { + // Don't do if we could do an indexed load on the original type, but not on + // the new one. + if (!LoadVT.isSimple() || !BitcastVT.isSimple()) + return true; + + MVT LoadMVT = LoadVT.getSimpleVT(); + + // Don't bother doing this if it's just going to be promoted again later, as + // doing so might interfere with other combines. + if (getOperationAction(ISD::LOAD, LoadMVT) == Promote && + getTypeToPromoteTo(ISD::LOAD, LoadMVT) == BitcastVT.getSimpleVT()) + return false; + + unsigned Fast = 0; + return allowsMemoryAccess(*DAG.getContext(), DAG.getDataLayout(), BitcastVT, + MMO, &Fast) && + Fast; +} + void TargetLoweringBase::finalizeLowering(MachineFunction &MF) const { MF.getRegInfo().freezeReservedRegs(MF); } |