diff options
Diffstat (limited to 'llvm/lib/IR/ConstantRange.cpp')
| -rw-r--r-- | llvm/lib/IR/ConstantRange.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/IR/ConstantRange.cpp b/llvm/lib/IR/ConstantRange.cpp index 08041c96ffe5..19041704a40b 100644 --- a/llvm/lib/IR/ConstantRange.cpp +++ b/llvm/lib/IR/ConstantRange.cpp @@ -364,6 +364,23 @@ ConstantRange ConstantRange::makeExactNoWrapRegion(Instruction::BinaryOps BinOp, return makeGuaranteedNoWrapRegion(BinOp, ConstantRange(Other), NoWrapKind); } +ConstantRange ConstantRange::makeMaskNotEqualRange(const APInt &Mask, + const APInt &C) { + unsigned BitWidth = Mask.getBitWidth(); + + if ((Mask & C) != C) + return getFull(BitWidth); + + if (Mask.isZero()) + return getEmpty(BitWidth); + + // If (Val & Mask) != C, constrained to the non-equality being + // satisfiable, then the value must be larger than the lowest set bit of + // Mask, offset by constant C. + return ConstantRange::getNonEmpty( + APInt::getOneBitSet(BitWidth, Mask.countr_zero()) + C, C); +} + bool ConstantRange::isFullSet() const { return Lower == Upper && Lower.isMaxValue(); } |
