forked from OSchip/llvm-project
[ValueTracking] Convert test to unit test (NFC)
Test this directly, rather than going through InstSimplify.
This commit is contained in:
parent
6c24b59ca1
commit
7cf0f8568c
|
@ -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 }
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue