mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
Add completely hokey binary-and and binary-or operations to ConstantRange and
teach LazyValueInfo to use them. llvm-svn: 113196
This commit is contained in:
parent
8c155b346e
commit
9698dae1df
@ -224,6 +224,14 @@ public:
|
||||
/// \p Other.
|
||||
ConstantRange udiv(const ConstantRange &Other) const;
|
||||
|
||||
/// binaryAnd - return a new range representing the possible values resulting
|
||||
/// from a binary-and of a value in this range by a value in \p Other.
|
||||
ConstantRange binaryAnd(const ConstantRange &Other) const;
|
||||
|
||||
/// binaryOr - return a new range representing the possible values resulting
|
||||
/// from a binary-or of a value in this range by a value in \p Other.
|
||||
ConstantRange binaryOr(const ConstantRange &Other) const;
|
||||
|
||||
/// shl - Return a new range representing the possible values resulting
|
||||
/// from a left shift of a value in this range by a value in \p Other.
|
||||
/// TODO: This isn't fully implemented yet.
|
||||
|
@ -602,6 +602,12 @@ LVILatticeVal LVIQuery::getBlockValue(BasicBlock *BB) {
|
||||
case Instruction::BitCast:
|
||||
Result.markConstantRange(LHSRange);
|
||||
break;
|
||||
case Instruction::And:
|
||||
Result.markConstantRange(LHSRange.binaryAnd(RHSRange));
|
||||
break;
|
||||
case Instruction::Or:
|
||||
Result.markConstantRange(LHSRange.binaryOr(RHSRange));
|
||||
break;
|
||||
|
||||
// Unhandled instructions are overdefined.
|
||||
default:
|
||||
|
@ -607,6 +607,32 @@ ConstantRange::udiv(const ConstantRange &RHS) const {
|
||||
return ConstantRange(Lower, Upper);
|
||||
}
|
||||
|
||||
ConstantRange
|
||||
ConstantRange::binaryAnd(const ConstantRange &Other) const {
|
||||
if (isEmptySet() || Other.isEmptySet())
|
||||
return ConstantRange(getBitWidth(), /*isFullSet=*/false);
|
||||
|
||||
// TODO: replace this with something less conservative
|
||||
|
||||
APInt umin = APIntOps::umin(Other.getUnsignedMax(), getUnsignedMax());
|
||||
if (umin.isAllOnesValue())
|
||||
return ConstantRange(getBitWidth(), /*isFullSet=*/true);
|
||||
return ConstantRange(APInt::getNullValue(getBitWidth()), umin + 1);
|
||||
}
|
||||
|
||||
ConstantRange
|
||||
ConstantRange::binaryOr(const ConstantRange &Other) const {
|
||||
if (isEmptySet() || Other.isEmptySet())
|
||||
return ConstantRange(getBitWidth(), /*isFullSet=*/false);
|
||||
|
||||
// TODO: replace this with something less conservative
|
||||
|
||||
APInt umax = APIntOps::umax(getUnsignedMin(), Other.getUnsignedMin());
|
||||
if (umax.isMinValue())
|
||||
return ConstantRange(getBitWidth(), /*isFullSet=*/true);
|
||||
return ConstantRange(umax, APInt::getNullValue(getBitWidth()));
|
||||
}
|
||||
|
||||
ConstantRange
|
||||
ConstantRange::shl(const ConstantRange &Other) const {
|
||||
if (isEmptySet() || Other.isEmptySet())
|
||||
|
Loading…
Reference in New Issue
Block a user