[llvm-commits] [llvm] r168815 - /llvm/trunk/unittests/VMCore/IRBuilderTest.cpp
Chandler Carruth
chandlerc at google.com
Wed Nov 28 13:23:53 PST 2012
On Wed, Nov 28, 2012 at 1:19 PM, Michael Ilseman <milseman at apple.com> wrote:
> Author: milseman
> Date: Wed Nov 28 15:19:52 2012
> New Revision: 168815
>
> URL: http://llvm.org/viewvc/llvm-project?rev=168815&view=rev
> Log:
> Fixed bad test case
Not sure how this is fixing a test case, it appears to be *adding* a
test case...
>
> Modified:
> llvm/trunk/unittests/VMCore/IRBuilderTest.cpp
>
> Modified: llvm/trunk/unittests/VMCore/IRBuilderTest.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/VMCore/IRBuilderTest.cpp?rev=168815&r1=168814&r2=168815&view=diff
> ==============================================================================
> --- llvm/trunk/unittests/VMCore/IRBuilderTest.cpp (original)
> +++ llvm/trunk/unittests/VMCore/IRBuilderTest.cpp Wed Nov 28 15:19:52 2012
> @@ -166,4 +166,59 @@
>
> }
>
> +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());
> +
> +}
> +
> }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list