diff options
author | Juneyoung Lee <aqjune@gmail.com> | 2021-01-05 10:09:49 +0900 |
---|---|---|
committer | Juneyoung Lee <aqjune@gmail.com> | 2021-01-06 12:10:33 +0900 |
commit | 29f8628d1fc8d96670e13562c4d92fc916bd0ce1 (patch) | |
tree | 1da50486f952374694247a04233515a2ff98c1e8 /llvm/unittests/Analysis/ValueTrackingTest.cpp | |
parent | 8444a2494d3d58baae373e66f8a7070e03c62cc2 (diff) | |
download | llvm-29f8628d1fc8d96670e13562c4d92fc916bd0ce1.zip llvm-29f8628d1fc8d96670e13562c4d92fc916bd0ce1.tar.gz llvm-29f8628d1fc8d96670e13562c4d92fc916bd0ce1.tar.bz2 |
[Constant] Add containsPoisonElement
This patch
- Adds containsPoisonElement that checks existence of poison in constant vector elements,
- Renames containsUndefElement to containsUndefOrPoisonElement to clarify its behavior & updates its uses properly
With this patch, isGuaranteedNotToBeUndefOrPoison's tests w.r.t constant vectors are added because its analysis is improved.
Thanks!
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D94053
Diffstat (limited to 'llvm/unittests/Analysis/ValueTrackingTest.cpp')
-rw-r--r-- | llvm/unittests/Analysis/ValueTrackingTest.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/unittests/Analysis/ValueTrackingTest.cpp b/llvm/unittests/Analysis/ValueTrackingTest.cpp index 0d65774..d70fd6e 100644 --- a/llvm/unittests/Analysis/ValueTrackingTest.cpp +++ b/llvm/unittests/Analysis/ValueTrackingTest.cpp @@ -888,6 +888,30 @@ TEST_F(ValueTrackingTest, isGuaranteedNotToBeUndefOrPoison) { EXPECT_EQ(isGuaranteedNotToBeUndefOrPoison(PoisonValue::get(IntegerType::get(Context, 8))), false); EXPECT_EQ(isGuaranteedNotToBePoison(UndefValue::get(IntegerType::get(Context, 8))), true); EXPECT_EQ(isGuaranteedNotToBePoison(PoisonValue::get(IntegerType::get(Context, 8))), false); + + Type *Int32Ty = Type::getInt32Ty(Context); + Constant *CU = UndefValue::get(Int32Ty); + Constant *CP = PoisonValue::get(Int32Ty); + Constant *C1 = ConstantInt::get(Int32Ty, 1); + Constant *C2 = ConstantInt::get(Int32Ty, 2); + + { + Constant *V1 = ConstantVector::get({C1, C2}); + EXPECT_TRUE(isGuaranteedNotToBeUndefOrPoison(V1)); + EXPECT_TRUE(isGuaranteedNotToBePoison(V1)); + } + + { + Constant *V2 = ConstantVector::get({C1, CU}); + EXPECT_FALSE(isGuaranteedNotToBeUndefOrPoison(V2)); + EXPECT_TRUE(isGuaranteedNotToBePoison(V2)); + } + + { + Constant *V3 = ConstantVector::get({C1, CP}); + EXPECT_FALSE(isGuaranteedNotToBeUndefOrPoison(V3)); + EXPECT_FALSE(isGuaranteedNotToBePoison(V3)); + } } TEST_F(ValueTrackingTest, isGuaranteedNotToBeUndefOrPoison_assume) { |