30 bool CompareOpcodes) {
36 return (!GEP1 || GEP1->getNumOperands() == 2) &&
37 (!GEP2 || GEP2->getNumOperands() == 2) &&
38 (((!GEP1 ||
isConstant(GEP1->getOperand(1))) &&
42 getSameOpcode({GEP1->getOperand(1), GEP2->getOperand(1)}, TLI)));
50 return CommonAlignment;
60 const SCEV *PtrSCEVLowest =
nullptr;
61 const SCEV *PtrSCEVHighest =
nullptr;
64 for (
Value *Ptr : PointerOps) {
69 if (!PtrSCEVLowest && !PtrSCEVHighest) {
70 PtrSCEVLowest = PtrSCEVHighest = PtrSCEV;
77 PtrSCEVLowest = PtrSCEV;
84 PtrSCEVHighest = PtrSCEV;
92 int Size =
DL.getTypeStoreSize(ElemTy);
93 auto TryGetStride = [&](
const SCEV *Dist,
94 const SCEV *Multiplier) ->
const SCEV * {
96 if (M->getOperand(0) == Multiplier)
97 return M->getOperand(1);
98 if (M->getOperand(1) == Multiplier)
99 return M->getOperand(0);
102 if (Multiplier == Dist)
107 const SCEV *Stride =
nullptr;
108 if (
Size != 1 || SCEVs.
size() > 1) {
110 Stride = TryGetStride(Dist, Sz);
118 using DistOrdPair = std::pair<int64_t, int>;
120 std::set<DistOrdPair,
decltype(Compare)> Offsets(Compare);
121 bool IsConsecutive =
true;
122 for (
const auto [Idx, PtrSCEV] :
enumerate(SCEVs)) {
124 if (PtrSCEV != PtrSCEVLowest) {
126 const SCEV *Coeff = TryGetStride(Diff, Stride);
136 Dist = SC->getAPInt().getZExtValue();
141 auto Res = Offsets.emplace(Dist, Idx);
145 IsConsecutive = IsConsecutive && std::next(Res.first) == Offsets.end();
147 SortedIndices.
clear();
148 if (!IsConsecutive) {
151 for (
const auto [Idx, Pair] :
enumerate(Offsets))
152 SortedIndices[Idx] = Pair.second;
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static MaybeAlign getAlign(Value *Ptr)
Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
Get the array size.
const T & consume_front()
consume_front() - Returns the first element and drops it from ArrayRef.
A parsed version of the target data layout string in and methods for querying it.
This class represents an analyzed expression in the program.
LLVM_ABI bool isZero() const
Return true if the expression is a constant zero.
LLVM_ABI bool isNonConstantNegative() const
Return true if the specified scev is negated, but not a constant.
Type * getType() const
Return the LLVM type of this SCEV expression.
The main scalar evolution driver.
LLVM_ABI const SCEV * getConstant(ConstantInt *V)
LLVM_ABI const SCEV * getSCEV(Value *V)
Return a SCEV expression for the full generality of the specified expression.
LLVM_ABI const SCEV * getMinusSCEV(SCEVUse LHS, SCEVUse RHS, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap, unsigned Depth=0)
Return LHS-RHS.
LLVM_ABI const SCEV * getMulExpr(SmallVectorImpl< SCEVUse > &Ops, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap, unsigned Depth=0)
Get a canonical multiply expression, or something simpler if possible.
LLVM_ABI const SCEV * getAddExpr(SmallVectorImpl< SCEVUse > &Ops, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap, unsigned Depth=0)
Get a canonical add expression, or something simpler if possible.
LLVM_ABI const SCEV * getUDivExactExpr(SCEVUse LHS, SCEVUse RHS)
Get a canonical unsigned division expression, or something simpler if possible.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Provides information about what library functions are available for the current target.
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
A private "module" namespace for types and utilities used by this pass.
template Align computeCommonAlignment< StoreInst >(ArrayRef< Value * >)
Align computeCommonAlignment(ArrayRef< Value * > VL)
Calculates minimal alignment as a common alignment.
template Align computeCommonAlignment< LoadInst >(ArrayRef< Value * >)
const SCEV * calculateRtStride(ArrayRef< Value * > PointerOps, Type *ElemTy, const DataLayout &DL, ScalarEvolution &SE, SmallVectorImpl< unsigned > &SortedIndices)
Checks if the provided list of pointers Pointers represents the strided pointers for type ElemTy.
InstructionsState getSameOpcode(ArrayRef< Value * > VL, const TargetLibraryInfo &TLI)
bool arePointersCompatible(Value *Ptr1, Value *Ptr2, const TargetLibraryInfo &TLI, unsigned MaxDepth, bool CompareOpcodes)
MaxDepth is the recursion limit for getUnderlyingObject.
bool isConstant(Value *V)
This is an optimization pass for GlobalISel generic memory operations.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI const Value * getUnderlyingObject(const Value *V, unsigned MaxLookup=MaxLookupSearchDepth)
This method strips off any GEP address adjustments, pointer casts or llvm.threadlocal....
This struct is a compact representation of a valid (non-zero power of two) alignment.
Function object to check whether the first component of a container supported by std::get (like std::...