[llvm] 7cf0f85 - [ValueTracking] Convert test to unit test (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sun May 3 03:24:09 PDT 2020
Author: Nikita Popov
Date: 2020-05-03T12:23:57+02:00
New Revision: 7cf0f8568cea18591d8481d3f274a5f27046d39d
URL: https://github.com/llvm/llvm-project/commit/7cf0f8568cea18591d8481d3f274a5f27046d39d
DIFF: https://github.com/llvm/llvm-project/commit/7cf0f8568cea18591d8481d3f274a5f27046d39d.diff
LOG: [ValueTracking] Convert test to unit test (NFC)
Test this directly, rather than going through InstSimplify.
Added:
Modified:
llvm/unittests/Analysis/ValueTrackingTest.cpp
Removed:
llvm/test/Analysis/ValueTracking/knownnonzero-shift.ll
################################################################################
diff --git a/llvm/test/Analysis/ValueTracking/knownnonzero-shift.ll b/llvm/test/Analysis/ValueTracking/knownnonzero-shift.ll
deleted file mode 100644
index c91e53157840..000000000000
--- a/llvm/test/Analysis/ValueTracking/knownnonzero-shift.ll
+++ /dev/null
@@ -1,15 +0,0 @@
-; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt -instsimplify -S < %s | FileCheck %s
-
-define i1 @test(i8 %p, i8* %pq) {
-; CHECK-LABEL: @test(
-; CHECK-NEXT: ret i1 true
-;
- %q = load i8, i8* %pq, !range !0 ; %q is known nonzero; no known bits
- %1 = shl i8 %p, %q ; because %q is nonzero, %1[0] is known to be zero.
- %2 = and i8 %1, 1
- %x = icmp eq i8 %2, 0
- ret i1 %x
-}
-
-!0 = !{ i8 1, i8 5 }
diff --git a/llvm/unittests/Analysis/ValueTrackingTest.cpp b/llvm/unittests/Analysis/ValueTrackingTest.cpp
index 250e4ee950a2..5e2feae24f9d 100644
--- a/llvm/unittests/Analysis/ValueTrackingTest.cpp
+++ b/llvm/unittests/Analysis/ValueTrackingTest.cpp
@@ -773,6 +773,19 @@ TEST_F(ComputeKnownBitsTest, ComputeKnownMulBits) {
expectKnownBits(/*zero*/ 95u, /*one*/ 32u);
}
+TEST_F(ComputeKnownBitsTest, KnownNonZeroShift) {
+ // %q is known nonzero without known bits.
+ // Because %q is nonzero, %A[0] is known to be zero.
+ parseAssembly(
+ "define i8 @test(i8 %p, i8* %pq) {\n"
+ " %q = load i8, i8* %pq, !range !0\n"
+ " %A = shl i8 %p, %q\n"
+ " ret i8 %A\n"
+ "}\n"
+ "!0 = !{ i8 1, i8 5 }\n");
+ expectKnownBits(/*zero*/ 1u, /*one*/ 0u);
+}
+
TEST_F(ComputeKnownBitsTest, ComputeKnownFshl) {
// fshl(....1111....0000, 00..1111........, 6)
// = 11....000000..11
More information about the llvm-commits
mailing list