LLVM 17.0.0git
|
#include "llvm/CodeGen/GlobalISel/CombinerHelper.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallBitVector.h"
#include "llvm/CodeGen/GlobalISel/GISelChangeObserver.h"
#include "llvm/CodeGen/GlobalISel/GISelKnownBits.h"
#include "llvm/CodeGen/GlobalISel/GenericMachineInstrs.h"
#include "llvm/CodeGen/GlobalISel/LegalizerHelper.h"
#include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
#include "llvm/CodeGen/GlobalISel/MIPatternMatch.h"
#include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h"
#include "llvm/CodeGen/GlobalISel/Utils.h"
#include "llvm/CodeGen/LowLevelType.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineDominators.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineMemOperand.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/RegisterBankInfo.h"
#include "llvm/CodeGen/TargetInstrInfo.h"
#include "llvm/CodeGen/TargetLowering.h"
#include "llvm/CodeGen/TargetOpcodes.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/DivisionByConstantInfo.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Target/TargetMachine.h"
#include <cmath>
#include <optional>
#include <tuple>
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "gi-combiner" |
Functions | |
static unsigned | littleEndianByteAt (const unsigned ByteWidth, const unsigned I) |
static Register | buildLogBase2 (Register V, MachineIRBuilder &MIB) |
Determines the LogBase2 value for a non-null input value using the transform: LogBase2(V) = (EltBits - 1) - ctlz(V). | |
static unsigned | bigEndianByteAt (const unsigned ByteWidth, const unsigned I) |
static std::optional< bool > | isBigEndian (const SmallDenseMap< int64_t, int64_t, 8 > &MemOffset2Idx, int64_t LowestIdx) |
Given a map from byte offsets in memory to indices in a load/store, determine if that map corresponds to a little or big endian byte pattern. | |
static unsigned | getExtLoadOpcForExtend (unsigned ExtOpc) |
static Type * | getTypeForLLT (LLT Ty, LLVMContext &C) |
static std::optional< APFloat > | constantFoldFpUnary (unsigned Opcode, LLT DstTy, const Register Op, const MachineRegisterInfo &MRI) |
static Register | peekThroughBitcast (Register Reg, const MachineRegisterInfo &MRI) |
static LLT | getMidVTForTruncRightShiftCombine (LLT ShiftTy, LLT TruncTy) |
static bool | isConstValidTrue (const TargetLowering &TLI, unsigned ScalarSizeBits, int64_t Cst, bool IsVector, bool IsFP) |
static std::optional< std::pair< GZExtLoad *, int64_t > > | matchLoadAndBytePosition (Register Reg, unsigned MemSizeInBits, const MachineRegisterInfo &MRI) |
Helper function for findLoadOffsetsForLoadOrCombine. | |
static std::optional< int64_t > | getTruncStoreByteOffset (GStore &Store, Register &SrcVal, MachineRegisterInfo &MRI) |
Check if the store Store is a truncstore that can be merged. | |
static bool | isContractableFMul (MachineInstr &MI, bool AllowFusionGlobally) |
Checks if MI is TargetOpcode::G_FMUL and contractable either due to global flags or MachineInstr flags. | |
static bool | hasMoreUses (const MachineInstr &MI0, const MachineInstr &MI1, const MachineRegisterInfo &MRI) |
Variables | |
static cl::opt< bool > | ForceLegalIndexing ("force-legal-indexing", cl::Hidden, cl::init(false), cl::desc("Force all indexed operations to be " "legal for the GlobalISel combiner")) |
#define DEBUG_TYPE "gi-combiner" |
Definition at line 39 of file CombinerHelper.cpp.
I
in a ByteWidth
bytes wide type.E.g. Given a 4-byte type x, x[0] -> byte 3
Definition at line 89 of file CombinerHelper.cpp.
Referenced by isBigEndian(), and llvm::CombinerHelper::matchLoadOrCombine().
|
static |
Determines the LogBase2 value for a non-null input value using the transform: LogBase2(V) = (EltBits - 1) - ctlz(V).
Definition at line 77 of file CombinerHelper.cpp.
References llvm::sampleprof::Base, llvm::MachineIRBuilder::buildConstant(), llvm::MachineIRBuilder::buildCTLZ(), llvm::MachineIRBuilder::buildSub(), llvm::MachineIRBuilder::getMRI(), llvm::MachineInstrBuilder::getReg(), llvm::LLT::getScalarSizeInBits(), and MRI.
Referenced by llvm::CombinerHelper::applyUMulHToLShr().
|
static |
Definition at line 1292 of file CombinerHelper.cpp.
References llvm::getConstantFPVRegVal(), llvm::getFltSemanticForLLT(), llvm::ConstantFP::getValueAPF(), llvm::APFloatBase::IEEEdouble(), llvm_unreachable, llvm::log2(), MRI, and llvm::APFloatBase::rmNearestTiesToEven.
Referenced by llvm::CombinerHelper::matchCombineConstantFoldFpUnary().
Definition at line 495 of file CombinerHelper.cpp.
References llvm_unreachable.
Referenced by llvm::CombinerHelper::applyCombineExtendingLoads(), and llvm::CombinerHelper::matchCombineExtendingLoads().
Definition at line 2281 of file CombinerHelper.cpp.
References llvm::LLT::changeElementSize(), and llvm::LLT::getScalarSizeInBits().
Referenced by llvm::CombinerHelper::matchCombineTruncOfShift().
|
static |
Check if the store Store
is a truncstore that can be merged.
That is, it's a store of a shifted value of SrcVal
. If SrcVal
is an empty Register then it does not need to match and SrcVal is set to the source value found. On match, returns the start byte offset of the SrcVal
that is being stored.
Definition at line 3635 of file CombinerHelper.cpp.
References llvm::Register::isValid(), llvm::MIPatternMatch::m_any_of(), llvm::MIPatternMatch::m_GAShr(), llvm::MIPatternMatch::m_GLShr(), llvm::MIPatternMatch::m_GTrunc(), llvm::MIPatternMatch::m_ICst(), llvm::MIPatternMatch::m_Reg(), llvm::MIPatternMatch::mi_match(), MRI, and llvm::Offset.
Referenced by llvm::CombinerHelper::matchTruncStoreMerge().
|
static |
Definition at line 1268 of file CombinerHelper.cpp.
References llvm::CallingConv::C, llvm::IntegerType::get(), llvm::FixedVectorType::get(), llvm::LLT::getNumElements(), llvm::LLT::getScalarSizeInBits(), llvm::LLT::getSizeInBits(), and llvm::LLT::isVector().
Referenced by llvm::CombinerHelper::matchPtrAddImmedChain().
|
static |
Definition at line 5318 of file CombinerHelper.cpp.
References llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), and MRI.
Referenced by llvm::CombinerHelper::matchCombineFAddFMAFMulToFMadOrFMA(), llvm::CombinerHelper::matchCombineFAddFMulToFMadOrFMA(), llvm::CombinerHelper::matchCombineFAddFpExtFMulToFMadOrFMA(), llvm::CombinerHelper::matchCombineFAddFpExtFMulToFMadOrFMAAggressive(), and llvm::CombinerHelper::matchCombineFSubFMulToFMadOrFMA().
|
static |
Given a map from byte offsets in memory to indices in a load/store, determine if that map corresponds to a little or big endian byte pattern.
MemOffset2Idx | maps memory offsets to address offsets. |
LowestIdx | is the lowest index in MemOffset2Idx . |
E.g. given a 32-bit type x, and x[AddrOffset], the in-memory byte patterns are as follows:
AddrOffset Little endian Big endian 0 0 3 1 1 2 2 2 1 3 3 0
Definition at line 112 of file CombinerHelper.cpp.
References assert(), bigEndianByteAt(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), Idx, littleEndianByteAt(), and llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::size().
Referenced by collectInsertionElements(), createGPRPairNode(), llvm::SelectionDAG::getConstant(), llvm::CombinerHelper::matchLoadOrCombine(), PerformSTORECombine(), llvm::LegalizerHelper::reduceLoadStoreWidth(), ReplaceCMP_SWAP_64Results(), and llvm::orc::OrcMips32_Base::writeResolverCode().
|
static |
Definition at line 2987 of file CombinerHelper.cpp.
References llvm::isConstTrueVal().
Referenced by llvm::CombinerHelper::matchNotCmp().
|
static |
Checks if MI
is TargetOpcode::G_FMUL and contractable either due to global flags or MachineInstr flags.
Definition at line 5312 of file CombinerHelper.cpp.
References llvm::MachineInstr::FmContract, and MI.
Referenced by llvm::CombinerHelper::matchCombineFAddFMAFMulToFMadOrFMA(), llvm::CombinerHelper::matchCombineFAddFMulToFMadOrFMA(), llvm::CombinerHelper::matchCombineFAddFpExtFMulToFMadOrFMA(), llvm::CombinerHelper::matchCombineFAddFpExtFMulToFMadOrFMAAggressive(), llvm::CombinerHelper::matchCombineFSubFMulToFMadOrFMA(), llvm::CombinerHelper::matchCombineFSubFNegFMulToFMadOrFMA(), llvm::CombinerHelper::matchCombineFSubFpExtFMulToFMadOrFMA(), and llvm::CombinerHelper::matchCombineFSubFpExtFNegFMulToFMadOrFMA().
I
in a ByteWidth
bytes wide type.E.g. Given a 4-byte type x, x[0] -> byte 0
Definition at line 70 of file CombinerHelper.cpp.
Referenced by isBigEndian(), and llvm::CombinerHelper::matchLoadOrCombine().
|
static |
Helper function for findLoadOffsetsForLoadOrCombine.
Check if Reg
is the result of loading a MemSizeInBits
wide value, and then moving that value into a specific byte offset.
e.g. x[i] << 24
Definition at line 3355 of file CombinerHelper.cpp.
References assert(), llvm::MIPatternMatch::m_GShl(), llvm::MIPatternMatch::m_ICst(), llvm::MIPatternMatch::m_OneNonDBGUse(), llvm::MIPatternMatch::m_Reg(), llvm::MIPatternMatch::mi_match(), and MRI.
|
static |
Definition at line 1722 of file CombinerHelper.cpp.
References llvm::MIPatternMatch::m_GBitcast(), llvm::MIPatternMatch::m_Reg(), llvm::MIPatternMatch::mi_match(), and MRI.
Referenced by llvm::CombinerHelper::matchCombineUnmergeMergeToPlainValues().
|
static |
Referenced by llvm::CombinerHelper::matchCombineIndexedLoadStore().