[llvm] [ConstantRange][LVI] Add initial support for `multiplyWithNoWrap` (PR #92356)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri May 24 10:13:54 PDT 2024
================
@@ -1019,18 +1023,102 @@ TEST_F(ConstantRangeTest, Multiply) {
});
}
+TEST_F(ConstantRangeTest, MultiplyWithNoWrap) {
+ using OBO = OverflowingBinaryOperator;
+
+ EXPECT_EQ(Empty.multiplyWithNoWrap(Some, OBO::NoUnsignedWrap), Empty);
+ EXPECT_EQ(Some.multiplyWithNoWrap(Empty, OBO::NoUnsignedWrap), Empty);
+ EXPECT_EQ(Full.multiplyWithNoWrap(Full, OBO::NoUnsignedWrap), Full);
+ EXPECT_EQ(Full.multiplyWithNoWrap(Some, OBO::NoUnsignedWrap), Full);
+ EXPECT_EQ(Some.multiplyWithNoWrap(Full, OBO::NoUnsignedWrap), Full);
+ EXPECT_EQ(ConstantRange(APInt(4, 0), APInt(4, 2))
+ .multiplyWithNoWrap(ConstantRange(APInt(4, 2), APInt(4, 0)),
+ OBO::NoUnsignedWrap),
+ ConstantRange(4, true));
----------------
nikic wrote:
```suggestion
ConstantRange::getFull(4));
```
https://github.com/llvm/llvm-project/pull/92356
More information about the llvm-commits
mailing list