[PATCH] D129876: [WIP][ConstantRange] Add support for multiply and left shift with nowrap flags
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 15 12:07:15 PDT 2022
nikic added a comment.
> I don't understand the bits in add/sub about being required to return empty ranges on definite overflow. I can see that from a precision perspective, but since both the 2s complement and saturating variants are valid implementations of the no-wrap behavior, it seems like intersecting them should always be valid. Am I right here? Or is my code subtly wrong?
There is no requirement to return an empty range. I believe the existing code is only pedantic about this so that tests can prove both correctness and optimality.
> Suggestions on how to test this? I glanced at the ConstantRangeTest file, and am looking for specific guidance on which exhaustive test harness to use. This file has gotten quite complicated.
The generic testing framework is TestBinaryOpExhaustive. For the second callback, return an `Optional<APInt>` only if no overflow occurs. For the third callback, you probably want PreferSmallestUnsigned or PreferSmallestSigned depending on the PreferredRangeType. The fourth one depends on whether your implementation provides optimal results, at least for some subsets.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D129876/new/
https://reviews.llvm.org/D129876
More information about the llvm-commits
mailing list