Lines Matching refs:RK
71 RetainedKnowledge canonicalizedKnowledge(RetainedKnowledge RK, in canonicalizedKnowledge() argument
73 switch (RK.AttrKind) { in canonicalizedKnowledge()
75 return RK; in canonicalizedKnowledge()
77 RK.WasOn = getUnderlyingObject(RK.WasOn); in canonicalizedKnowledge()
78 return RK; in canonicalizedKnowledge()
80 Value *V = RK.WasOn->stripInBoundsOffsets([&](const Value *Strip) { in canonicalizedKnowledge()
82 RK.ArgValue = in canonicalizedKnowledge()
83 MinAlign(RK.ArgValue, GEP->getMaxPreservedAlignment(DL).value()); in canonicalizedKnowledge()
85 RK.WasOn = V; in canonicalizedKnowledge()
86 return RK; in canonicalizedKnowledge()
91 Value *V = GetPointerBaseWithConstantOffset(RK.WasOn, Offset, DL, in canonicalizedKnowledge()
94 return RK; in canonicalizedKnowledge()
95 RK.ArgValue = RK.ArgValue + Offset; in canonicalizedKnowledge()
96 RK.WasOn = V; in canonicalizedKnowledge()
99 return RK; in canonicalizedKnowledge()
117 bool tryToPreserveWithoutAddingAssume(RetainedKnowledge RK) { in tryToPreserveWithoutAddingAssume()
118 if (!InstBeingModified || !RK.WasOn) in tryToPreserveWithoutAddingAssume()
123 RK.WasOn, {RK.AttrKind}, AC, in tryToPreserveWithoutAddingAssume()
128 if (RKOther.ArgValue >= RK.ArgValue) { in tryToPreserveWithoutAddingAssume()
141 ConstantInt::get(Type::getInt64Ty(M->getContext()), RK.ArgValue)); in tryToPreserveWithoutAddingAssume()
145 bool isKnowledgeWorthPreserving(RetainedKnowledge RK) { in isKnowledgeWorthPreserving()
146 if (!RK) in isKnowledgeWorthPreserving()
148 if (!RK.WasOn) in isKnowledgeWorthPreserving()
150 if (RK.WasOn->getType()->isPointerTy()) { in isKnowledgeWorthPreserving()
151 Value *UnderlyingPtr = getUnderlyingObject(RK.WasOn); in isKnowledgeWorthPreserving()
155 if (auto *Arg = dyn_cast<Argument>(RK.WasOn)) { in isKnowledgeWorthPreserving()
156 if (Arg->hasAttribute(RK.AttrKind) && in isKnowledgeWorthPreserving()
157 (!Attribute::isIntAttrKind(RK.AttrKind) || in isKnowledgeWorthPreserving()
158 Arg->getAttribute(RK.AttrKind).getValueAsInt() >= RK.ArgValue)) in isKnowledgeWorthPreserving()
162 if (auto *Inst = dyn_cast<Instruction>(RK.WasOn)) in isKnowledgeWorthPreserving()
164 if (RK.WasOn->use_empty()) in isKnowledgeWorthPreserving()
166 Use *SingleUse = RK.WasOn->getSingleUndroppableUse(); in isKnowledgeWorthPreserving()
173 void addKnowledge(RetainedKnowledge RK) { in addKnowledge()
174 RK = canonicalizedKnowledge(RK, M->getDataLayout()); in addKnowledge()
176 if (!isKnowledgeWorthPreserving(RK)) in addKnowledge()
179 if (tryToPreserveWithoutAddingAssume(RK)) in addKnowledge()
181 MapKey Key{RK.WasOn, RK.AttrKind}; in addKnowledge()
184 AssumedKnowledgeMap[Key] = RK.ArgValue; in addKnowledge()
187 assert(((Lookup->second == 0 && RK.ArgValue == 0) || in addKnowledge()
188 (Lookup->second != 0 && RK.ArgValue != 0)) && in addKnowledge()
193 Lookup->second = std::max(Lookup->second, RK.ArgValue); in addKnowledge()
311 for (const RetainedKnowledge &RK : Knowledge) in buildAssumeFromKnowledge() local
312 Builder.addKnowledge(RK); in buildAssumeFromKnowledge()
317 RetainedKnowledge RK, in simplifyRetainedKnowledge() argument
321 RK = canonicalizedKnowledge(RK, Assume->getModule()->getDataLayout()); in simplifyRetainedKnowledge()
323 if (!Builder.isKnowledgeWorthPreserving(RK)) in simplifyRetainedKnowledge()
326 if (Builder.tryToPreserveWithoutAddingAssume(RK)) in simplifyRetainedKnowledge()
328 return RK; in simplifyRetainedKnowledge()
420 RetainedKnowledge RK = in dropRedundantKnowledge() local
422 if (auto *Arg = dyn_cast_or_null<Argument>(RK.WasOn)) { in dropRedundantKnowledge()
423 bool HasSameKindAttr = Arg->hasAttribute(RK.AttrKind); in dropRedundantKnowledge()
425 if (!Attribute::isIntAttrKind(RK.AttrKind) || in dropRedundantKnowledge()
426 Arg->getAttribute(RK.AttrKind).getValueAsInt() >= in dropRedundantKnowledge()
427 RK.ArgValue) { in dropRedundantKnowledge()
435 Arg->removeAttr(RK.AttrKind); in dropRedundantKnowledge()
436 Arg->addAttr(Attribute::get(C, RK.AttrKind, RK.ArgValue)); in dropRedundantKnowledge()
442 auto &Lookup = Knowledge[{RK.WasOn, RK.AttrKind}]; in dropRedundantKnowledge()
446 if (Elem.ArgValue >= RK.ArgValue) { in dropRedundantKnowledge()
451 ConstantInt::get(Type::getInt64Ty(C), RK.ArgValue)); in dropRedundantKnowledge()
457 Lookup.push_back({Assume, RK.ArgValue, &BOI}); in dropRedundantKnowledge()
480 RetainedKnowledge RK = in mergeRange() local
482 if (!RK) in mergeRange()
484 Builder.addKnowledge(RK); in mergeRange()
485 if (auto *I = dyn_cast_or_null<Instruction>(RK.WasOn)) in mergeRange()