diff options
Diffstat (limited to 'unittests/IR/IRBuilderTest.cpp')
-rw-r--r-- | unittests/IR/IRBuilderTest.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/unittests/IR/IRBuilderTest.cpp b/unittests/IR/IRBuilderTest.cpp index 1812cd39d135..830ae9587691 100644 --- a/unittests/IR/IRBuilderTest.cpp +++ b/unittests/IR/IRBuilderTest.cpp @@ -207,7 +207,26 @@ TEST_F(IRBuilderTest, FastMathFlags) { EXPECT_TRUE(FCmp->hasAllowReciprocal()); Builder.clearFastMathFlags(); - + + // Test FP-contract + FC = Builder.CreateFAdd(F, F); + ASSERT_TRUE(isa<Instruction>(FC)); + FAdd = cast<Instruction>(FC); + EXPECT_FALSE(FAdd->hasAllowContract()); + + FMF.clear(); + FMF.setAllowContract(true); + Builder.setFastMathFlags(FMF); + + FC = Builder.CreateFAdd(F, F); + EXPECT_TRUE(Builder.getFastMathFlags().any()); + EXPECT_TRUE(Builder.getFastMathFlags().AllowContract); + ASSERT_TRUE(isa<Instruction>(FC)); + FAdd = cast<Instruction>(FC); + EXPECT_TRUE(FAdd->hasAllowContract()); + + Builder.clearFastMathFlags(); + // Test a call with FMF. auto CalleeTy = FunctionType::get(Type::getFloatTy(Ctx), /*isVarArg=*/false); @@ -245,6 +264,7 @@ TEST_F(IRBuilderTest, FastMathFlags) { EXPECT_FALSE(FDiv->getFastMathFlags().any()); FDiv->setHasAllowReciprocal(true); FAdd->setHasAllowReciprocal(false); + FAdd->setHasNoNaNs(true); FDiv->copyFastMathFlags(FAdd); EXPECT_TRUE(FDiv->hasNoNaNs()); EXPECT_FALSE(FDiv->hasAllowReciprocal()); |