Go to the documentation of this file.
19 #define DEBUG_TYPE "assume-queries"
24 STATISTIC(NumAssumeQueries,
"Number of Queries into an assume assume bundles");
26 NumUsefullAssumeQueries,
27 "Number of Queries into an assume assume bundles that were satisfied");
30 "Controls which assumes gets created");
46 "this attribute doesn't exist");
49 "requested value for an attribute that has no argument");
54 if (BOI.Tag->getKey() != AttrName)
56 if (IsOn && (BOI.End - BOI.Begin <=
ABA_WasOn ||
72 std::pair<Value *, Attribute::AttrKind>
Key{
80 Result[
Key][&Assume] = {0, 0};
83 auto *CI = dyn_cast<ConstantInt>(
89 if (
Lookup == Result.end() || !
Lookup->second.count(&Assume)) {
90 Result[
Key][&Assume] = {Val, Val};
105 auto GetArgOr1 = [&](
unsigned Idx) ->
uint64_t {
106 if (
auto *ConstInt = dyn_cast<ConstantInt>(
108 return ConstInt->getZExtValue();
112 Result.ArgValue = GetArgOr1(0);
113 if (Result.AttrKind == Attribute::Alignment)
115 Result.ArgValue =
MinAlign(Result.ArgValue, GetArgOr1(1));
128 return BOI.Tag->getKey() != IgnoreBundleTag;
133 if (!
match(U->getUser(),
136 auto *
Intr = cast<IntrinsicInst>(U->getUser());
137 return &
Intr->getBundleOpInfoForOperand(U->getOperandNo());
165 auto *II = cast_or_null<AssumeInst>(Elem.Assume);
169 *II, II->bundle_op_info_begin()[Elem.Index])) {
173 Filter(RK, II, &II->bundle_op_info_begin()[Elem.Index])) {
174 NumUsefullAssumeQueries++;
181 for (
const auto &U : V->
uses()) {
188 Filter(RK, cast<Instruction>(U.getUser()), Bundle)) {
189 NumUsefullAssumeQueries++;
This is an optimization pass for GlobalISel generic memory operations.
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly.
RetainedKnowledge getKnowledgeFromUse(const Use *U, ArrayRef< Attribute::AttrKind > AttrKinds)
Return a valid Knowledge associated to the Use U if its Attribute kind is in AttrKinds.
StringMapEntry< uint32_t > * Tag
The operand bundle tag, interned by LLVMContextImpl::getOrInsertBundleTag.
static Attribute::AttrKind getAttrKindFromName(StringRef AttrName)
static bool isIntAttrKind(AttrKind Kind)
static Value * getValueFromBundleOpInfo(AssumeInst &Assume, const CallBase::BundleOpInfo &BOI, unsigned Idx)
bool isAssumeWithEmptyBundle(AssumeInst &Assume)
Return true iff the operand bundles of the provided llvm.assume doesn't contain any valuable informat...
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
This represents the llvm.assume intrinsic.
iterator_range< bundle_op_iterator > bundle_op_infos()
Return the range [bundle_op_info_begin, bundle_op_info_end).
match_unless< Ty > m_Unless(const Ty &M)
Match if the inner matcher does NOT match.
constexpr uint64_t MinAlign(uint64_t A, uint64_t B)
A and B are either alignments or offsets.
bool isValidAssumeForContext(const Instruction *I, const Instruction *CxtI, const DominatorTree *DT=nullptr)
Return true if it is valid to use the assumptions provided by an assume intrinsic,...
bool match(Val *V, const Pattern &P)
static CallInst::BundleOpInfo * getBundleFromUse(const Use *U)
BundleOpInfo & getBundleOpInfoForOperand(unsigned OpIdx)
Return the BundleOpInfo for the operand at index OpIdx.
bool hasAttributeInAssume(AssumeInst &Assume, Value *IsOn, StringRef AttrName, uint64_t *ArgVal=nullptr)
Query the operand bundle of an llvm.assume to find a single attribute of the specified kind applied o...
iterator_range< use_iterator > uses()
uint32_t Begin
The index in the Use& vector where operands for this operand bundle starts.
static bool shouldExecute(unsigned CounterName)
STATISTIC(NumFunctions, "Total number of functions")
Used to keep track of an operand bundle.
RetainedKnowledge getKnowledgeFromBundle(AssumeInst &Assume, const CallBase::BundleOpInfo &BOI)
This extracts the Knowledge from an element of an operand bundle.
An efficient, type-erasing, non-owning reference to a callable.
Attribute::AttrKind AttrKind
@ None
No attributes have been set.
static RetainedKnowledge none()
void fillMapFromAssume(AssumeInst &Assume, RetainedKnowledgeMap &Result)
Insert into the map all the informations contained in the operand bundles of the llvm....
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Expected< ExpressionValue > min(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
StringRef - Represent a constant reference to a string, i.e.
A cache of @llvm.assume calls within a function.
Represent one information held inside an operand bundle of an llvm.assume.
uint32_t End
The index in the Use& vector where operands for this operand bundle ends.
static bool isExistingAttribute(StringRef Name)
Return true if the provided string matches the IR name of an attribute.
static int Lookup(ArrayRef< TableEntry > Table, unsigned Opcode)
static bool bundleHasArgument(const CallBase::BundleOpInfo &BOI, unsigned Idx)
specificval_ty m_Specific(const Value *V)
Match if we have a specific specified value.
RetainedKnowledge getKnowledgeValidInContext(const Value *V, ArrayRef< Attribute::AttrKind > AttrKinds, const Instruction *CtxI, const DominatorTree *DT=nullptr, AssumptionCache *AC=nullptr)
Return a valid Knowledge associated to the Value V if its Attribute kind is in AttrKinds and the know...
Align max(MaybeAlign Lhs, Align Rhs)
DEBUG_COUNTER(AssumeQueryCounter, "assume-queries-counter", "Controls which assumes gets created")
RetainedKnowledge getKnowledgeFromOperandInAssume(AssumeInst &Assume, unsigned Idx)
Retreive the information help by Assume on the operand at index Idx.
LLVM Value Representation.
A Use represents the edge between a Value definition and its users.
RetainedKnowledge getKnowledgeForValue(const Value *V, ArrayRef< Attribute::AttrKind > AttrKinds, AssumptionCache *AC=nullptr, function_ref< bool(RetainedKnowledge, Instruction *, const CallBase::BundleOpInfo *)> Filter=[](auto...) { return true;})
Return a valid Knowledge associated to the Value V if its Attribute kind is in AttrKinds and it match...
MutableArrayRef< ResultElem > assumptionsFor(const Value *V)
Access the list of assumptions which affect this value.