本文整理汇总了C++中ConstantRange::makeGuaranteedNoWrapRegion方法的典型用法代码示例。如果您正苦于以下问题:C++ ConstantRange::makeGuaranteedNoWrapRegion方法的具体用法?C++ ConstantRange::makeGuaranteedNoWrapRegion怎么用?C++ ConstantRange::makeGuaranteedNoWrapRegion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConstantRange
的用法示例。
在下文中一共展示了ConstantRange::makeGuaranteedNoWrapRegion方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processAdd
static bool processAdd(BinaryOperator *AddOp, LazyValueInfo *LVI) {
typedef OverflowingBinaryOperator OBO;
if (DontProcessAdds)
return false;
if (AddOp->getType()->isVectorTy() || hasLocalDefs(AddOp))
return false;
bool NSW = AddOp->hasNoSignedWrap();
bool NUW = AddOp->hasNoUnsignedWrap();
if (NSW && NUW)
return false;
BasicBlock *BB = AddOp->getParent();
Value *LHS = AddOp->getOperand(0);
Value *RHS = AddOp->getOperand(1);
ConstantRange LRange = LVI->getConstantRange(LHS, BB, AddOp);
// Initialize RRange only if we need it. If we know that guaranteed no wrap
// range for the given LHS range is empty don't spend time calculating the
// range for the RHS.
Optional<ConstantRange> RRange;
auto LazyRRange = [&] () {
if (!RRange)
RRange = LVI->getConstantRange(RHS, BB, AddOp);
return RRange.getValue();
};
bool Changed = false;
if (!NUW) {
ConstantRange NUWRange =
LRange.makeGuaranteedNoWrapRegion(BinaryOperator::Add, LRange,
OBO::NoUnsignedWrap);
if (!NUWRange.isEmptySet()) {
bool NewNUW = NUWRange.contains(LazyRRange());
AddOp->setHasNoUnsignedWrap(NewNUW);
Changed |= NewNUW;
}
}
if (!NSW) {
ConstantRange NSWRange =
LRange.makeGuaranteedNoWrapRegion(BinaryOperator::Add, LRange,
OBO::NoSignedWrap);
if (!NSWRange.isEmptySet()) {
bool NewNSW = NSWRange.contains(LazyRRange());
AddOp->setHasNoSignedWrap(NewNSW);
Changed |= NewNSW;
}
}
return Changed;
}