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);
192 std::optional<ValueAndVReg> MaybeIndex =
203 B.buildCopy(Dst, Build->
getSourceReg(MaybeIndex->Value.getZExtValue()));
253 std::optional<ValueAndVReg> MaybeIndex =
270 B.buildTrunc(Dst, Build->
getSourceReg(MaybeIndex->Value.getZExtValue()));
320 std::optional<ValueAndVReg> MaybeIndex =
330 unsigned Offset = MaybeIndex->Value.getZExtValue();
331 int SrcIdx = Mask[
Offset];
336 assert(Src1Type.
isVector() &&
"expected to extract from a vector");
356 if (SrcIdx < (
int)LHSWidth) {
369 {TargetOpcode::G_EXTRACT_VECTOR_ELT, {DstTy, NewVectorTy, IdxTy}}) ||
375 auto Idx =
B.buildConstant(IdxTy, SrcIdx);
376 B.buildExtractVectorElement(Dst, NewVector,
Idx);
393 std::optional<ValueAndVReg> MaybeIndex =
396 if (MaybeIndex && MaybeIndex->Value.uge(DstTy.
getNumElements()) &&
418 B.buildVScale(Dst, LHSVScale->
getSrc() + RHSVScale->
getSrc());
439 B.buildVScale(Dst, LHSVScale->
getSrc() * *MaybeRHS);
458 auto VScale =
B.buildVScale(DstTy, -RHSVScale->
getSrc());
482 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.
APInt shl(unsigned shiftAmt) const
Left-shift function.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
bool matchMulOfVScale(const MachineOperand &MO, BuildFnTy &MatchInfo)
bool matchSubOfVScale(const MachineOperand &MO, BuildFnTy &MatchInfo)
bool matchExtractVectorElementWithDifferentIndices(const MachineOperand &MO, BuildFnTy &MatchInfo)
Combine extract vector element with a insert vector element on the vector register and different indi...
bool matchExtractVectorElementWithBuildVectorTrunc(const MachineOperand &MO, BuildFnTy &MatchInfo)
Combine extract vector element with a build vector trunc on the vector register.
const TargetLowering & getTargetLowering() const
bool matchAddOfVScale(const MachineOperand &MO, BuildFnTy &MatchInfo)
bool matchInsertVectorElementOOB(MachineInstr &MI, BuildFnTy &MatchInfo)
Combine insert vector element OOB.
bool isConstantLegalOrBeforeLegalizer(const LLT Ty) const
bool matchShlOfVScale(const MachineOperand &MO, BuildFnTy &MatchInfo)
bool matchExtractVectorElementWithShuffleVector(const MachineOperand &MO, BuildFnTy &MatchInfo)
Combine extract vector element with a shuffle vector on the vector register.
MachineRegisterInfo & MRI
bool isLegalOrBeforeLegalizer(const LegalityQuery &Query) const
bool matchExtractVectorElementWithBuildVector(const MachineOperand &MO, BuildFnTy &MatchInfo)
Combine extract vector element with a build vector on the vector register.
bool matchExtractVectorElement(MachineInstr &MI, BuildFnTy &MatchInfo)
Combine extract vector element.
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
@ 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...