28#define DEBUG_TYPE "gi-combiner"
31using namespace MIPatternMatch;
72 std::optional<ValueAndVReg> MaybeIndex =
74 std::optional<APInt> IndexC = std::nullopt;
77 IndexC = MaybeIndex->Value;
114 std::optional<ValueAndVReg> MaybeIndex =
116 std::optional<APInt> IndexC = std::nullopt;
121 IndexC = MaybeIndex->Value;
126 getOpcodeDef<GInsertVectorElement>(
Vector,
MRI);
132 std::optional<ValueAndVReg> MaybeInsertIndex =
135 if (MaybeInsertIndex && MaybeInsertIndex->Value != *IndexC) {
140 B.buildExtractVectorElement(Dst, Insert->getVectorReg(), Index);
232 std::optional<ValueAndVReg> MaybeIndex =
249 B.buildTrunc(Dst, Build->
getSourceReg(MaybeIndex->Value.getZExtValue()));
290 unsigned Offset = Index.getZExtValue();
291 int SrcIdx = Mask[
Offset];
296 assert(Src1Type.
isVector() &&
"expected to extract from a vector");
316 if (SrcIdx < (
int)LHSWidth) {
329 {TargetOpcode::G_EXTRACT_VECTOR_ELT, {DstTy, NewVectorTy, IdxTy}}) ||
335 auto Idx =
B.buildConstant(IdxTy, SrcIdx);
336 B.buildExtractVectorElement(Dst, NewVector,
Idx);
348 Register Index = Insert->getIndexReg();
353 std::optional<ValueAndVReg> MaybeIndex =
356 if (MaybeIndex && MaybeIndex->Value.uge(DstTy.
getNumElements()) &&
378 B.buildVScale(Dst, LHSVScale->
getSrc() + RHSVScale->
getSrc());
399 B.buildVScale(Dst, LHSVScale->
getSrc() * *MaybeRHS);
418 auto VScale =
B.buildVScale(DstTy, -RHSVScale->
getSrc());
442 B.buildVScale(Dst, LHSVScale->
getSrc().
shl(*MaybeRHS));
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This contains common combine transformations that may be used in a combine pass,or by the target else...
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
Declares convenience wrapper classes for interpreting MachineInstr instances as specific generic oper...
Interface for Targets to specify which operations they can successfully select and how the others sho...
Implement a low-level type suitable for MachineInstr level instruction selection.
Contains matchers for matching SSA Machine Instructions.
This file declares the MachineIRBuilder class.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file describes how to lower LLVM code to machine code.
Class for arbitrary precision integers.
APInt shl(unsigned shiftAmt) const
Left-shift function.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
bool matchExtractVectorElementWithBuildVectorTrunc(const MachineOperand &MO, BuildFnTy &MatchInfo) const
Combine extract vector element with a build vector trunc on the vector register.
const TargetLowering & getTargetLowering() const
bool matchExtractVectorElementWithDifferentIndices(const MachineOperand &MO, BuildFnTy &MatchInfo) const
Combine extract vector element with a insert vector element on the vector register and different indi...
bool matchInsertVectorElementOOB(MachineInstr &MI, BuildFnTy &MatchInfo) const
Combine insert vector element OOB.
bool matchExtractVectorElement(MachineInstr &MI, BuildFnTy &MatchInfo) const
Combine extract vector element.
bool matchMulOfVScale(const MachineOperand &MO, BuildFnTy &MatchInfo) const
bool matchAddOfVScale(const MachineOperand &MO, BuildFnTy &MatchInfo) const
bool matchShlOfVScale(const MachineOperand &MO, BuildFnTy &MatchInfo) const
bool matchExtractVectorElementWithShuffleVector(const MachineInstr &MI, const MachineInstr &MI2, BuildFnTy &MatchInfo) const
Combine extract vector element with a shuffle vector on the vector register.
bool isConstantLegalOrBeforeLegalizer(const LLT Ty) const
MachineRegisterInfo & MRI
bool isLegalOrBeforeLegalizer(const LegalityQuery &Query) const
bool matchSubOfVScale(const MachineOperand &MO, BuildFnTy &MatchInfo) const
bool matchExtractVectorElementWithBuildVector(const MachineInstr &MI, const MachineInstr &MI2, BuildFnTy &MatchInfo) const
Combine extract vector element with a build vector on the vector register.
Represents an integer addition.
Register getLHSReg() const
Register getRHSReg() const
Represents a G_BUILD_VECTOR_TRUNC.
Represents a G_BUILD_VECTOR.
Represents an insert vector element.
Register getSourceReg(unsigned I) const
Returns the I'th source register.
Represents an integer multiplication.
Register getShiftReg() const
Register getSrcReg() const
Represents a G_SHUFFLE_VECTOR.
Register getSrc2Reg() const
Register getSrc1Reg() const
ArrayRef< int > getMask() const
Represents an integer subtraction.
Register getReg(unsigned Idx) const
Access the Idx'th operand as a register and return it.
constexpr uint16_t getNumElements() const
Returns the number of elements in a vector LLT.
constexpr bool isVector() const
constexpr bool isFixedVector() const
Returns true if the LLT is a fixed vector.
Helper class to build MachineInstr.
Representation of each machine instruction.
uint32_t getFlags() const
Return the MI flags bitvector.
MachineOperand class - Representation of each machine instruction operand.
Register getReg() const
getReg - Returns the register number.
bool hasOneNonDBGUse(Register RegNo) const
hasOneNonDBGUse - Return true if there is exactly one non-Debug use of the specified register.
MachineInstr * getVRegDef(Register Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
LLT getType(Register Reg) const
Get the low-level type of Reg or LLT{} if Reg is not a generic (target independent) virtual register.
Wrapper class representing virtual and physical registers.
This is an optimization pass for GlobalISel generic memory operations.
std::optional< APInt > getIConstantVRegVal(Register VReg, const MachineRegisterInfo &MRI)
If VReg is defined by a G_CONSTANT, return the corresponding value.
MVT getMVTForLLT(LLT Ty)
Get a rough equivalent of an MVT for a given LLT.
MachineInstr * getDefIgnoringCopies(Register Reg, const MachineRegisterInfo &MRI)
Find the def instruction for Reg, folding away any trivial copies.
std::function< void(MachineIRBuilder &)> BuildFnTy
const APInt & getIConstantFromReg(Register VReg, const MachineRegisterInfo &MRI)
VReg is defined by a G_CONSTANT, return the corresponding value.
@ Mul
Product of integers.
std::optional< ValueAndVReg > getIConstantVRegValWithLookThrough(Register VReg, const MachineRegisterInfo &MRI, bool LookThroughInstrs=true)
If VReg is defined by a statically evaluable chain of instructions rooted on a G_CONSTANT returns its...