Lines Matching refs:RK
70 RetainedKnowledge canonicalizedKnowledge(RetainedKnowledge RK, in canonicalizedKnowledge() argument
72 switch (RK.AttrKind) { in canonicalizedKnowledge()
74 return RK; in canonicalizedKnowledge()
76 RK.WasOn = getUnderlyingObject(RK.WasOn); in canonicalizedKnowledge()
77 return RK; in canonicalizedKnowledge()
79 Value *V = RK.WasOn->stripInBoundsOffsets([&](const Value *Strip) { in canonicalizedKnowledge()
81 RK.ArgValue = in canonicalizedKnowledge()
82 MinAlign(RK.ArgValue, GEP->getMaxPreservedAlignment(DL).value()); in canonicalizedKnowledge()
84 RK.WasOn = V; in canonicalizedKnowledge()
85 return RK; in canonicalizedKnowledge()
90 Value *V = GetPointerBaseWithConstantOffset(RK.WasOn, Offset, DL, in canonicalizedKnowledge()
93 return RK; in canonicalizedKnowledge()
94 RK.ArgValue = RK.ArgValue + Offset; in canonicalizedKnowledge()
95 RK.WasOn = V; in canonicalizedKnowledge()
98 return RK; in canonicalizedKnowledge()
116 bool tryToPreserveWithoutAddingAssume(RetainedKnowledge RK) { in tryToPreserveWithoutAddingAssume()
117 if (!InstBeingModified || !RK.WasOn) in tryToPreserveWithoutAddingAssume()
122 RK.WasOn, {RK.AttrKind}, AC, in tryToPreserveWithoutAddingAssume()
127 if (RKOther.ArgValue >= RK.ArgValue) { in tryToPreserveWithoutAddingAssume()
140 ConstantInt::get(Type::getInt64Ty(M->getContext()), RK.ArgValue)); in tryToPreserveWithoutAddingAssume()
144 bool isKnowledgeWorthPreserving(RetainedKnowledge RK) { in isKnowledgeWorthPreserving()
145 if (!RK) in isKnowledgeWorthPreserving()
147 if (!RK.WasOn) in isKnowledgeWorthPreserving()
149 if (RK.WasOn->getType()->isPointerTy()) { in isKnowledgeWorthPreserving()
150 Value *UnderlyingPtr = getUnderlyingObject(RK.WasOn); in isKnowledgeWorthPreserving()
154 if (auto *Arg = dyn_cast<Argument>(RK.WasOn)) { in isKnowledgeWorthPreserving()
155 if (Arg->hasAttribute(RK.AttrKind) && in isKnowledgeWorthPreserving()
156 (!Attribute::isIntAttrKind(RK.AttrKind) || in isKnowledgeWorthPreserving()
157 Arg->getAttribute(RK.AttrKind).getValueAsInt() >= RK.ArgValue)) in isKnowledgeWorthPreserving()
161 if (auto *Inst = dyn_cast<Instruction>(RK.WasOn)) in isKnowledgeWorthPreserving()
163 if (RK.WasOn->use_empty()) in isKnowledgeWorthPreserving()
165 Use *SingleUse = RK.WasOn->getSingleUndroppableUse(); in isKnowledgeWorthPreserving()
172 void addKnowledge(RetainedKnowledge RK) { in addKnowledge()
173 RK = canonicalizedKnowledge(RK, M->getDataLayout()); in addKnowledge()
175 if (!isKnowledgeWorthPreserving(RK)) in addKnowledge()
178 if (tryToPreserveWithoutAddingAssume(RK)) in addKnowledge()
180 MapKey Key{RK.WasOn, RK.AttrKind}; in addKnowledge()
183 AssumedKnowledgeMap[Key] = RK.ArgValue; in addKnowledge()
186 assert(((Lookup->second == 0 && RK.ArgValue == 0) || in addKnowledge()
187 (Lookup->second != 0 && RK.ArgValue != 0)) && in addKnowledge()
192 Lookup->second = std::max(Lookup->second, RK.ArgValue); in addKnowledge()
313 for (const RetainedKnowledge &RK : Knowledge) in buildAssumeFromKnowledge() local
314 Builder.addKnowledge(RK); in buildAssumeFromKnowledge()
319 RetainedKnowledge RK, in simplifyRetainedKnowledge() argument
323 RK = canonicalizedKnowledge(RK, Assume->getDataLayout()); in simplifyRetainedKnowledge()
325 if (!Builder.isKnowledgeWorthPreserving(RK)) in simplifyRetainedKnowledge()
328 if (Builder.tryToPreserveWithoutAddingAssume(RK)) in simplifyRetainedKnowledge()
330 return RK; in simplifyRetainedKnowledge()
422 RetainedKnowledge RK = in dropRedundantKnowledge() local
424 if (auto *Arg = dyn_cast_or_null<Argument>(RK.WasOn)) { in dropRedundantKnowledge()
425 bool HasSameKindAttr = Arg->hasAttribute(RK.AttrKind); in dropRedundantKnowledge()
427 if (!Attribute::isIntAttrKind(RK.AttrKind) || in dropRedundantKnowledge()
428 Arg->getAttribute(RK.AttrKind).getValueAsInt() >= in dropRedundantKnowledge()
429 RK.ArgValue) { in dropRedundantKnowledge()
437 Arg->removeAttr(RK.AttrKind); in dropRedundantKnowledge()
438 Arg->addAttr(Attribute::get(C, RK.AttrKind, RK.ArgValue)); in dropRedundantKnowledge()
444 auto &Lookup = Knowledge[{RK.WasOn, RK.AttrKind}]; in dropRedundantKnowledge()
448 if (Elem.ArgValue >= RK.ArgValue) { in dropRedundantKnowledge()
453 ConstantInt::get(Type::getInt64Ty(C), RK.ArgValue)); in dropRedundantKnowledge()
459 Lookup.push_back({Assume, RK.ArgValue, &BOI}); in dropRedundantKnowledge()
482 RetainedKnowledge RK = in mergeRange() local
484 if (!RK) in mergeRange()
486 Builder.addKnowledge(RK); in mergeRange()
487 if (auto *I = dyn_cast_or_null<Instruction>(RK.WasOn)) in mergeRange()