From 3dc7c7ca3115ba9294f72074fdea0bf9bf6f6b60 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 12 Apr 2019 19:36:47 +0000 Subject: [ConstantRange] Clarify makeGuaranteedNoWrapRegion() guarantees; NFC makeGuaranteedNoWrapRegion() is actually makeExactNoWrapRegion() as long as only one of NUW or NSW is specified. This is not obvious from the current documentation, and some code seems to think that it is only exact for single-element ranges. Clarify docs and add tests to be more confident this really holds. There are currently no users of makeGuaranteedNoWrapRegion() that pass both NUW and NSW. I think it would be best to drop support for this entirely and then rename the function to makeExactNoWrapRegion(). Knowing that the no-wrap region is exact is useful, because we can backwards-constrain values. What I have in mind in particular is that LVI should be able to constrain values on edges where the with.overflow overflow flag is false. Differential Revision: https://reviews.llvm.org/D60598 llvm-svn: 358305 --- llvm/lib/IR/ConstantRange.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'llvm/lib/IR/ConstantRange.cpp') diff --git a/llvm/lib/IR/ConstantRange.cpp b/llvm/lib/IR/ConstantRange.cpp index 35c2b0e2e2c..fe67059a892 100644 --- a/llvm/lib/IR/ConstantRange.cpp +++ b/llvm/lib/IR/ConstantRange.cpp @@ -869,8 +869,7 @@ ConstantRange::add(const ConstantRange &Other) const { ConstantRange ConstantRange::addWithNoSignedWrap(const APInt &Other) const { // Calculate the subset of this range such that "X + Other" is // guaranteed not to wrap (overflow) for all X in this subset. - // makeGuaranteedNoWrapRegion will produce an exact NSW range since we are - // passing a single element range. + // makeGuaranteedNoWrapRegion will produce an exact NSW range. auto NSWRange = ConstantRange::makeGuaranteedNoWrapRegion(BinaryOperator::Add, ConstantRange(Other), OverflowingBinaryOperator::NoSignedWrap); -- cgit v1.2.3