aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/IR/ConstantRangeTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/unittests/IR/ConstantRangeTest.cpp')
-rw-r--r--llvm/unittests/IR/ConstantRangeTest.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/unittests/IR/ConstantRangeTest.cpp b/llvm/unittests/IR/ConstantRangeTest.cpp
index 12facfb..e505af5 100644
--- a/llvm/unittests/IR/ConstantRangeTest.cpp
+++ b/llvm/unittests/IR/ConstantRangeTest.cpp
@@ -2438,6 +2438,20 @@ TEST_F(ConstantRangeTest, Ctlz) {
});
}
+TEST_F(ConstantRangeTest, Cttz) {
+ TestUnaryOpExhaustive(
+ [](const ConstantRange &CR) { return CR.cttz(); },
+ [](const APInt &N) { return APInt(N.getBitWidth(), N.countr_zero()); });
+
+ TestUnaryOpExhaustive(
+ [](const ConstantRange &CR) { return CR.cttz(/*ZeroIsPoison=*/true); },
+ [](const APInt &N) -> std::optional<APInt> {
+ if (N.isZero())
+ return std::nullopt;
+ return APInt(N.getBitWidth(), N.countr_zero());
+ });
+}
+
TEST_F(ConstantRangeTest, Ctpop) {
TestUnaryOpExhaustive(
[](const ConstantRange &CR) { return CR.ctpop(); },