diff options
author | Florian Hahn <florian.hahn@arm.com> | 2018-06-27 12:57:51 +0000 |
---|---|---|
committer | Florian Hahn <florian.hahn@arm.com> | 2018-06-27 12:57:51 +0000 |
commit | f681413e67a4e2b7a7ba54caba674a0023b30d15 (patch) | |
tree | 2206ae16cf6ace5063e24021717427b4224df108 /llvm/unittests/Analysis/ValueLatticeTest.cpp | |
parent | bb78eef6b682a62745c09892d47660fe44d8ac88 (diff) | |
download | bcm5719-llvm-f681413e67a4e2b7a7ba54caba674a0023b30d15.tar.gz bcm5719-llvm-f681413e67a4e2b7a7ba54caba674a0023b30d15.zip |
[ValueLattice] Return false if value range did not change in mergeIn.
llvm-svn: 335729
Diffstat (limited to 'llvm/unittests/Analysis/ValueLatticeTest.cpp')
-rw-r--r-- | llvm/unittests/Analysis/ValueLatticeTest.cpp | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/llvm/unittests/Analysis/ValueLatticeTest.cpp b/llvm/unittests/Analysis/ValueLatticeTest.cpp index b3e86c48b55..b0b379760a5 100644 --- a/llvm/unittests/Analysis/ValueLatticeTest.cpp +++ b/llvm/unittests/Analysis/ValueLatticeTest.cpp @@ -50,20 +50,26 @@ TEST_F(ValueLatticeTest, MergeIn) { // Merge to lattice values with equal integer constant. auto LV1 = ValueLatticeElement::get(C1); - LV1.mergeIn(ValueLatticeElement::get(C1), M.getDataLayout()); + EXPECT_FALSE(LV1.mergeIn(ValueLatticeElement::get(C1), M.getDataLayout())); EXPECT_TRUE(LV1.isConstantRange()); EXPECT_EQ(LV1.asConstantInteger().getValue().getLimitedValue(), 1U); // Merge LV1 with different integer constant. - LV1.mergeIn(ValueLatticeElement::get(ConstantInt::get(I32Ty, 99)), - M.getDataLayout()); + EXPECT_TRUE(LV1.mergeIn(ValueLatticeElement::get(ConstantInt::get(I32Ty, 99)), + M.getDataLayout())); + EXPECT_TRUE(LV1.isConstantRange()); + EXPECT_EQ(LV1.getConstantRange().getLower().getLimitedValue(), 1U); + EXPECT_EQ(LV1.getConstantRange().getUpper().getLimitedValue(), 100U); + + // Merge constant range with same constant range. + EXPECT_FALSE(LV1.mergeIn(LV1, M.getDataLayout())); EXPECT_TRUE(LV1.isConstantRange()); EXPECT_EQ(LV1.getConstantRange().getLower().getLimitedValue(), 1U); EXPECT_EQ(LV1.getConstantRange().getUpper().getLimitedValue(), 100U); // Merge LV1 in undefined value. ValueLatticeElement LV2; - LV2.mergeIn(LV1, M.getDataLayout()); + EXPECT_TRUE(LV2.mergeIn(LV1, M.getDataLayout())); EXPECT_TRUE(LV1.isConstantRange()); EXPECT_EQ(LV1.getConstantRange().getLower().getLimitedValue(), 1U); EXPECT_EQ(LV1.getConstantRange().getUpper().getLimitedValue(), 100U); @@ -71,8 +77,14 @@ TEST_F(ValueLatticeTest, MergeIn) { EXPECT_EQ(LV2.getConstantRange().getLower().getLimitedValue(), 1U); EXPECT_EQ(LV2.getConstantRange().getUpper().getLimitedValue(), 100U); - // Merge with overdefined. - LV1.mergeIn(ValueLatticeElement::getOverdefined(), M.getDataLayout()); + // Merge LV1 with overdefined. + EXPECT_TRUE( + LV1.mergeIn(ValueLatticeElement::getOverdefined(), M.getDataLayout())); + EXPECT_TRUE(LV1.isOverdefined()); + + // Merge overdefined with overdefined. + EXPECT_FALSE( + LV1.mergeIn(ValueLatticeElement::getOverdefined(), M.getDataLayout())); EXPECT_TRUE(LV1.isOverdefined()); } @@ -136,8 +148,9 @@ TEST_F(ValueLatticeTest, getCompareFloat) { EXPECT_TRUE(LV1.getCompare(CmpInst::FCMP_OLT, I1Ty, LV2)->isZeroValue()); EXPECT_TRUE(LV1.getCompare(CmpInst::FCMP_OGT, I1Ty, LV2)->isZeroValue()); - LV1.mergeIn(ValueLatticeElement::get(ConstantFP::get(FloatTy, 2.2)), - M.getDataLayout()); + EXPECT_TRUE( + LV1.mergeIn(ValueLatticeElement::get(ConstantFP::get(FloatTy, 2.2)), + M.getDataLayout())); EXPECT_EQ(LV1.getCompare(CmpInst::FCMP_OEQ, I1Ty, LV2), nullptr); EXPECT_EQ(LV1.getCompare(CmpInst::FCMP_OGE, I1Ty, LV2), nullptr); EXPECT_EQ(LV1.getCompare(CmpInst::FCMP_OLE, I1Ty, LV2), nullptr); |