diff options
author | Michael Ilseman <milseman@apple.com> | 2012-11-28 21:19:52 +0000 |
---|---|---|
committer | Michael Ilseman <milseman@apple.com> | 2012-11-28 21:19:52 +0000 |
commit | 9eec6599521ba64e59da4a5e5fdc79ba6964dbc6 (patch) | |
tree | dc4752b3c97f413e4e1ec1f51f5159a31d272572 /unittests | |
parent | f564e9ff2d3327dc122f55b8037da6d688a7deb4 (diff) |
Fixed bad test case
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168815 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r-- | unittests/VMCore/IRBuilderTest.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/unittests/VMCore/IRBuilderTest.cpp b/unittests/VMCore/IRBuilderTest.cpp index 0f3e48d76c..affd7b0fb1 100644 --- a/unittests/VMCore/IRBuilderTest.cpp +++ b/unittests/VMCore/IRBuilderTest.cpp @@ -166,4 +166,59 @@ TEST_F(IRBuilderTest, FastMathFlags) { } +TEST_F(IRBuilderTest, FastMathFlags) { + IRBuilder<> Builder(BB); + Value *F; + Instruction *FDiv, *FAdd; + + F = Builder.CreateLoad(GV); + F = Builder.CreateFAdd(F, F); + + EXPECT_FALSE(Builder.getFastMathFlags().any()); + ASSERT_TRUE(isa<Instruction>(F)); + FAdd = cast<Instruction>(F); + EXPECT_FALSE(FAdd->hasNoNaNs()); + + FastMathFlags FMF; + Builder.SetFastMathFlags(FMF); + + F = Builder.CreateFAdd(F, F); + EXPECT_FALSE(Builder.getFastMathFlags().any()); + + FMF.UnsafeAlgebra = true; + Builder.SetFastMathFlags(FMF); + + F = Builder.CreateFAdd(F, F); + EXPECT_TRUE(Builder.getFastMathFlags().any()); + ASSERT_TRUE(isa<Instruction>(F)); + FAdd = cast<Instruction>(F); + EXPECT_TRUE(FAdd->hasNoNaNs()); + + F = Builder.CreateFDiv(F, F); + EXPECT_TRUE(Builder.getFastMathFlags().any()); + EXPECT_TRUE(Builder.getFastMathFlags().UnsafeAlgebra); + ASSERT_TRUE(isa<Instruction>(F)); + FDiv = cast<Instruction>(F); + EXPECT_TRUE(FDiv->hasAllowReciprocal()); + + Builder.clearFastMathFlags(); + + F = Builder.CreateFDiv(F, F); + ASSERT_TRUE(isa<Instruction>(F)); + FDiv = cast<Instruction>(F); + EXPECT_FALSE(FDiv->hasAllowReciprocal()); + + FMF.clear(); + FMF.AllowReciprocal = true; + Builder.SetFastMathFlags(FMF); + + F = Builder.CreateFDiv(F, F); + EXPECT_TRUE(Builder.getFastMathFlags().any()); + EXPECT_TRUE(Builder.getFastMathFlags().AllowReciprocal); + ASSERT_TRUE(isa<Instruction>(F)); + FDiv = cast<Instruction>(F); + EXPECT_TRUE(FDiv->hasAllowReciprocal()); + +} + } |