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 | 1833e000a3a50463b8c0ede48c378b30e706dcec (patch) | |
tree | 11f2f553b78b4b6ae74214e2e88fa9bf1e27a236 /llvm/unittests | |
parent | 018530268dd5a29902c6a0f72fd25c61431eb2bd (diff) | |
download | bcm5719-llvm-1833e000a3a50463b8c0ede48c378b30e706dcec.tar.gz bcm5719-llvm-1833e000a3a50463b8c0ede48c378b30e706dcec.zip |
Fixed bad test case
llvm-svn: 168815
Diffstat (limited to 'llvm/unittests')
-rw-r--r-- | llvm/unittests/VMCore/IRBuilderTest.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/llvm/unittests/VMCore/IRBuilderTest.cpp b/llvm/unittests/VMCore/IRBuilderTest.cpp index 0f3e48d76c3..affd7b0fb16 100644 --- a/llvm/unittests/VMCore/IRBuilderTest.cpp +++ b/llvm/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()); + +} + } |