24 assert(Ty.isVector() &&
"vector shift count is not a vector type");
25 int64_t ElementBits = Ty.getScalarSizeInBits();
26 assert(ElementBits <= 64 &&
"expected <= 64bit shift type");
28 std::optional<APInt>
C;
32 for (
unsigned I = 0, E = BV->getNumSources();
I < E && !
C; ++
I)
39 Cnt =
C->getSExtValue();
40 return Cnt >= 1 && Cnt <= ElementBits;
56 if (!MaybeSub || MaybeSub->
getOpcode() != TargetOpcode::G_SUB ||
62 return MaybeZero && MaybeZero->Value.getZExtValue() == 0;
67 assert(
MI.getOpcode() == TargetOpcode::G_MEMSET);
72 {
MI.getOperand(0),
MI.getOperand(2)})
73 .addImm(
MI.getOperand(3).getImm())
82 assert(
MI.getOpcode() == TargetOpcode::G_MEMSET);
88 if (!
Zero ||
Zero->Value.getSExtValue() != 0)
98 MI.getOperand(2).getReg(),
MRI)) {
99 if (
Size->Value.getSExtValue() <= 256)
110 LLT DstTy =
MRI.getType(
MI.getOperand(0).getReg());
118 if (AndMI->getOpcode() != TargetOpcode::G_AND)
121 if (LShrMI->getOpcode() != TargetOpcode::G_LSHR)
129 if (!
V1.has_value() || !V2.has_value() || !
V3.has_value())
132 if (!
V1.value().isMask(HalfSize) || V2.value() != (1ULL | 1ULL << HalfSize) ||
133 V3 != (HalfSize - 1))
136 SrcReg = LShrMI->getOperand(1).getReg();
146 LLT DstTy =
MRI.getType(DstReg);
150 Register ZeroVec =
B.buildConstant(HalfTy, 0).getReg(0);
152 B.buildInstr(TargetOpcode::G_BITCAST, {HalfTy}, {SrcReg}).
getReg(0);
157 B.buildInstr(TargetOpcode::G_BITCAST, {DstReg}, {CMLTReg}).
getReg(0);
158 MI.eraseFromParent();
161std::tuple<uint16_t, Register>
165 uint16_t ConstDisc = 0;
168 if (
isUInt<16>(ConstDiscVal->getZExtValue())) {
169 ConstDisc = ConstDiscVal->getZExtValue();
172 return std::make_tuple(ConstDisc, AddrDisc);
175 Register BlendAddrDisc, BlendConstDisc;
178 m_Reg(BlendConstDisc))))
179 return std::make_tuple(ConstDisc, AddrDisc);
182 if (
isUInt<16>(ConstDiscVal->getZExtValue())) {
183 ConstDisc = ConstDiscVal->getZExtValue();
184 AddrDisc = BlendAddrDisc;
187 return std::make_tuple(ConstDisc, AddrDisc);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
Declares convenience wrapper classes for interpreting MachineInstr instances as specific generic oper...
Contains matchers for matching SSA Machine Instructions.
Promote Memory to Register
static MCRegister getReg(const MCDisassembler *D, unsigned RC, unsigned RegNo)
MachineRegisterInfo & MRI
This file describes how to lower LLVM code to machine code.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
@ FCMP_OEQ
0 0 0 1 True if ordered and equal
@ FCMP_TRUE
1 1 1 1 Always true (always folded)
@ ICMP_SLT
signed less than
@ FCMP_OLT
0 1 0 0 True if ordered and less than
@ FCMP_ULE
1 1 0 1 True if unordered, less than, or equal
@ FCMP_OGT
0 0 1 0 True if ordered and greater than
@ FCMP_OGE
0 0 1 1 True if ordered and greater than or equal
@ FCMP_ULT
1 1 0 0 True if unordered or less than
@ FCMP_ONE
0 1 1 0 True if ordered and operands are unequal
@ FCMP_UEQ
1 0 0 1 True if unordered or equal
@ FCMP_UGT
1 0 1 0 True if unordered or greater than
@ FCMP_OLE
0 1 0 1 True if ordered and less than or equal
@ FCMP_ORD
0 1 1 1 True if ordered (no nans)
@ FCMP_UNE
1 1 1 0 True if unordered or not equal
@ FCMP_UGE
1 0 1 1 True if unordered, greater than, or equal
@ FCMP_FALSE
0 0 0 0 Always false (always folded)
@ FCMP_UNO
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
static LLVM_ABI bool isEquality(Predicate pred)
Determine if this is an equals/not equals predicate.
Predicate getInversePredicate() const
For example, EQ -> NE, UGT -> ULE, SLT -> SGE, OEQ -> UNE, UGT -> OLE, OLT -> UGE,...
LLT changeElementCount(ElementCount EC) const
Return a vector or scalar with the same element type and the new element count.
constexpr unsigned getScalarSizeInBits() const
constexpr ElementCount getElementCount() const
static constexpr LLT fixed_vector(unsigned NumElements, unsigned ScalarSizeInBits)
Get a low-level fixed-width vector of some number of elements and element width.
LLT changeElementSize(unsigned NewEltSize) const
If this type is a vector, return a vector with the same number of elements but the new element size.
Tracks which library functions to use for a particular subtarget or function.
RTLIB::LibcallImpl getLibcallImpl(RTLIB::Libcall Call) const
Return the lowering's selection of implementation call for Call.
Helper class to build MachineInstr.
MachineInstrBuilder buildInstr(unsigned Opcode)
Build and insert <empty> = Opcode <empty>.
void setInstrAndDebugLoc(MachineInstr &MI)
Set the insertion point to before MI, and set the debug loc to MI's loc.
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
Representation of each machine instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
bool getFlag(MIFlag Flag) const
Return whether an MI flag is set.
const MachineOperand & getOperand(unsigned i) const
Register getReg() const
getReg - Returns the register number.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Wrapper class representing virtual and physical registers.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
std::tuple< uint16_t, Register > extractPtrauthBlendDiscriminators(Register Disc, MachineRegisterInfo &MRI)
Analyze a ptrauth discriminator value to try to find the constant integer and address parts,...
bool matchEmitBZero(const MachineInstr &MI, const MachineRegisterInfo &MRI, const LibcallLoweringInfo &Libcalls, bool MinSize)
Replace a G_MEMSET with a value of 0 with a G_BZERO instruction if it is supported and beneficial to ...
void changeFCMPPredToAArch64CC(const CmpInst::Predicate P, AArch64CC::CondCode &CondCode, AArch64CC::CondCode &CondCode2)
Find the AArch64 condition codes necessary to represent P for a scalar floating point comparison.
void applyCombineMulCMLT(MachineInstr &MI, MachineRegisterInfo &MRI, MachineIRBuilder &B, Register &SrcReg)
bool matchCombineMulCMLT(MachineInstr &MI, MachineRegisterInfo &MRI, Register &SrcReg)
Detect and apply Mul(And(Srl(X, 15), 0x10001), 0xffff) to CMLTz pattern.
bool isVShiftRImm(Register Reg, const MachineRegisterInfo &MRI, LLT Ty, int64_t &Cnt)
void changeVectorFCMPPredToAArch64CC(const CmpInst::Predicate P, AArch64CC::CondCode &CondCode, AArch64CC::CondCode &CondCode2, bool &Invert)
Find the AArch64 condition codes necessary to represent P for a vector floating point comparison.
bool isCMN(const MachineInstr *MaybeSub, const CmpInst::Predicate &Pred, const MachineRegisterInfo &MRI)
void applyEmitBZero(MachineInstr &MI, MachineIRBuilder &MIRBuilder)
Replace MI with a G_BZERO.
operand_type_match m_Reg()
bool mi_match(Reg R, const MachineRegisterInfo &MRI, Pattern &&P)
GInstrBind< GIntrinsic > m_GIntrinsic(GIntrinsic *&Inst)
Binds the defining instruction of Reg if it is a GIntrinsic (any of the four G_INTRINSIC* opcodes).
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI std::optional< APInt > isConstantOrConstantSplatVector(Register Def, const MachineRegisterInfo &MRI)
Determines if Def defines a constant integer or a splat vector of constant integers.
LLVM_ABI std::optional< APInt > getIConstantVRegVal(Register VReg, const MachineRegisterInfo &MRI)
If VReg is defined by a G_CONSTANT, return the corresponding value.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI MachineInstr * getDefIgnoringCopies(Register Reg, const MachineRegisterInfo &MRI)
Find the def instruction for Reg, folding away any trivial copies.
constexpr bool isUInt(uint64_t x)
Checks if an unsigned integer fits into the given bit width.
LLVM_ABI bool isBuildVectorConstantSplat(const Register Reg, const MachineRegisterInfo &MRI, int64_t SplatValue, bool AllowUndef)
Return true if the specified register is defined by G_BUILD_VECTOR or G_BUILD_VECTOR_TRUNC where all ...
LLVM_ABI 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...
LLVM_ABI std::optional< Register > getVectorSplat(const MachineInstr &MI, const MachineRegisterInfo &MRI)