aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/IR/ConstantRangeTest.cpp
diff options
context:
space:
mode:
authorYingwei Zheng <dtcxzyw2333@gmail.com>2023-11-06 15:59:50 +0800
committerGitHub <noreply@github.com>2023-11-06 15:59:50 +0800
commitb6deea1b53ae84806941c0a43e4f59d3aa40692a (patch)
tree6b839699da16deb8c5087701b2d51ed2924f6697 /llvm/unittests/IR/ConstantRangeTest.cpp
parenta07dbf1fb0f4ba36911233c82914a9ddf3eb4a09 (diff)
downloadllvm-b6deea1b53ae84806941c0a43e4f59d3aa40692a.zip
llvm-b6deea1b53ae84806941c0a43e4f59d3aa40692a.tar.gz
llvm-b6deea1b53ae84806941c0a43e4f59d3aa40692a.tar.bz2
[ConstantRange] Handle `Intrinsic::ctpop` (#68310)
This patch adds support for `Intrinsic::ctpop` in ConstantRange. It calculates the range in O(1) with the LCP-based method. Migrated from https://reviews.llvm.org/D153505.
Diffstat (limited to 'llvm/unittests/IR/ConstantRangeTest.cpp')
-rw-r--r--llvm/unittests/IR/ConstantRangeTest.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/unittests/IR/ConstantRangeTest.cpp b/llvm/unittests/IR/ConstantRangeTest.cpp
index 1cb358a..12facfb 100644
--- a/llvm/unittests/IR/ConstantRangeTest.cpp
+++ b/llvm/unittests/IR/ConstantRangeTest.cpp
@@ -2438,6 +2438,12 @@ TEST_F(ConstantRangeTest, Ctlz) {
});
}
+TEST_F(ConstantRangeTest, Ctpop) {
+ TestUnaryOpExhaustive(
+ [](const ConstantRange &CR) { return CR.ctpop(); },
+ [](const APInt &N) { return APInt(N.getBitWidth(), N.popcount()); });
+}
+
TEST_F(ConstantRangeTest, castOps) {
ConstantRange A(APInt(16, 66), APInt(16, 128));
ConstantRange FpToI8 = A.castOp(Instruction::FPToSI, 8);