[llvm] 989445f - [ValueTracking] add unit test for isKnownNonZero(); NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 14 05:06:35 PDT 2021
Author: Sanjay Patel
Date: 2021-04-14T08:06:26-04:00
New Revision: 989445f4386cdc1fce20eb4e418ed4b502819cc7
URL: https://github.com/llvm/llvm-project/commit/989445f4386cdc1fce20eb4e418ed4b502819cc7
DIFF: https://github.com/llvm/llvm-project/commit/989445f4386cdc1fce20eb4e418ed4b502819cc7.diff
LOG: [ValueTracking] add unit test for isKnownNonZero(); NFC
We call various value tracking APIs from within -instsimplify,
so I don't think this is visible in a larger test.
Added:
Modified:
llvm/unittests/Analysis/ValueTrackingTest.cpp
Removed:
################################################################################
diff --git a/llvm/unittests/Analysis/ValueTrackingTest.cpp b/llvm/unittests/Analysis/ValueTrackingTest.cpp
index 93bb2635b245..85678bb66530 100644
--- a/llvm/unittests/Analysis/ValueTrackingTest.cpp
+++ b/llvm/unittests/Analysis/ValueTrackingTest.cpp
@@ -1173,6 +1173,27 @@ TEST_F(ComputeKnownBitsTest, ComputeKnownMulBits) {
expectKnownBits(/*zero*/ 95u, /*one*/ 32u);
}
+TEST_F(ValueTrackingTest, isNonZeroRecurrence) {
+ parseAssembly(R"(
+ define i1 @test(i8 %n, i8 %r) {
+ entry:
+ br label %loop
+ loop:
+ %p = phi i8 [ -1, %entry ], [ %next, %loop ]
+ %next = add nsw i8 %p, -1
+ %cmp1 = icmp eq i8 %p, %n
+ br i1 %cmp1, label %exit, label %loop
+ exit:
+ %A = or i8 %p, %r
+ %CxtI = icmp eq i8 %A, 0
+ ret i1 %CxtI
+ }
+ )");
+ DataLayout DL = M->getDataLayout();
+ AssumptionCache AC(*F);
+ EXPECT_FALSE(isKnownNonZero(A, DL, 0, &AC, CxtI));
+}
+
TEST_F(ValueTrackingTest, KnownNonZeroFromDomCond) {
parseAssembly(R"(
declare i8* @f_i8()
More information about the llvm-commits
mailing list