28#define DEBUG_PREFIX_LOCAL DEBUG_PREFIX "LoadStoreVec: "
40 if (!Sched->trySchedule(Bndl))
46void LoadStoreVec::saveIR(
Region &R) {
49 CostBefore = SB.getAfterCost() - SB.getBeforeCost();
50 Rgn->getContext().save();
53bool LoadStoreVec::acceptOrRevert() {
58 <<
" (After=" << CostAfter <<
" Before=" << CostBefore
72 Loads, A->getScalarEvolution(), *DL))
74 if (!canVectorize(Loads))
92 for (
Value *Elm : AggrCOp->operands())
96 Constants.push_back(SeqCOp->getElementAsConstant(ElmIdx));
98 auto *ZeroElm =
Zero->getSequentialElement();
99 for ([[maybe_unused]]
auto Cnt :
104 for ([[maybe_unused]]
auto Cnt :
111 for ([[maybe_unused]]
auto Cnt :
125 Stores, A->getScalarEvolution(), *DL))
127 if (!canVectorize(Stores))
131 for (
auto *
I : Stores) {
144 if (LI->getParent() != BB)
146 if (LI->hasNUsesOrMore(2))
152 if (!AllLoads && !AllConstants)
158 Value *VecOp =
nullptr;
161 SmallVector<Instruction *, 8> Loads;
165 VecOp = createVectorLoad(Loads);
166 if (VecOp ==
nullptr) {
170 }
else if (AllConstants) {
171 VecOp = createConstantVector(
Operands);
181 DeadInstrMorgue.collectPotentiallyDeadInstrs(Stores);
183 DeadInstrMorgue.collectPotentiallyDeadInstrs<
Value>(
Operands);
184 DeadInstrMorgue.tryEraseDeadInstrs();
186 return acceptOrRevert();
192 Loads, A->getScalarEvolution(), *DL))
194 auto VecTy = canVectorize(Loads);
207 auto *
VecLoad = createVectorLoad(Loads);
208 if (VecLoad ==
nullptr) {
216 if (OrigLoad->hasNUses(0))
220 OrigLoad->replaceAllUsesWith(Unpacked);
223 DeadInstrMorgue.collectPotentiallyDeadInstrs(Loads);
224 DeadInstrMorgue.tryEraseDeadInstrs();
226 if (!acceptOrRevert())
235 Function &
F = *Bndl[0]->getParent()->getParent();
236 DL = &
F.getParent()->getDataLayout();
237 Ctx = &
F.getContext();
242 auto Opc = Bndl[0]->getOpcode();
245 "Expected a homogeneous seed slice!");
249 case Instruction::Opcode::Load:
250 Changed = vectorizeLoads(Bndl, Rgn) !=
nullptr;
252 case Instruction::Opcode::Store:
253 Changed = vectorizeStores(Bndl, Rgn);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file defines the DenseSet and SmallDenseSet classes.
This file defines an InstructionCost class that is used when calculating the cost of an instruction,...
static constexpr Value * getValue(Ty &ValueOrUse)
#define DEBUG_PREFIX_LOCAL
InstListType::iterator iterator
Instruction iterators...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An ArrayRef of Values or Instructions that we can print/dump for debugging.
static LLVM_ABI Constant * get(Type *Ty, double V)
This returns a ConstantFP, or a vector containing a splat of a ConstantFP, for the specified value in...
static LLVM_ABI Constant * get(Type *Ty, uint64_t V, bool IsSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
static LLVM_ABI Constant * get(ArrayRef< Constant * > V)
A sandboxir::User with operands, opcode and linked with previous/next instructions in an instruction ...
static bool areUnique(BndlRef< ValueT * > Values)
static bool differentBlock(BndlRef< ValueT * > Instrs)
static LLVM_ABI LoadInst * create(Type *Ty, Value *Ptr, MaybeAlign Align, InsertPosition Pos, bool IsVolatile, Context &Ctx, const Twine &Name="")
bool runOnRegion(Region &Rgn, const Analyses &A) final
\Returns true if it modifies R.
static LLVM_ABI StoreInst * create(Value *V, Value *Ptr, MaybeAlign Align, InsertPosition Pos, bool IsVolatile, Context &Ctx)
A SandboxIR Value has users. This is the base class.
static Instruction * getLowest(ArrayRef< Instruction * > Instrs)
\Returns the instruction in Instrs that is lowest in the BB.
static Type * getCombinedVectorTypeFor(ArrayRef< Instruction * > Bndl, const DataLayout &DL)
\Returns the combined vector type for Bndl, even when the element types differ.
static Value * unpack(Value *FromVec, Type *ExtrTy, unsigned Lane, BasicBlock::iterator WhereIt)
Emits the necessary instruction sequence to extract element of type ExtrTy at Lane from FromVec.
static auto enumerateLanes(const ValueContainerT &Range)
Helper for creating LaneValueEnumerator ranges.
static bool areConsecutive(LoadOrStoreT *I1, LoadOrStoreT *I2, ScalarEvolution &SE, const DataLayout &DL)
\Returns true if I1 and I2 are load/stores accessing consecutive memory addresses.
static Type * getElementType(Type *Ty)
Returns Ty if scalar or its element type if vector.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
BndlRef(const T &OneElt) -> BndlRef< T >
BasicBlock(llvm::BasicBlock *BB, Context &SBCtx)
friend class Instruction
Iterator for Instructions in a `BasicBlock.
This is an optimization pass for GlobalISel generic memory operations.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
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...
DWARFExpression::Operation Op
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
constexpr auto seq(T Begin, T End)
Iterate over an integral type from Begin up to - but not including - End.
static cl::opt< unsigned > CostThreshold("dfa-cost-threshold", cl::desc("Maximum cost accepted for the transformation"), cl::Hidden, cl::init(50))