diff options
author | Adam Nemet <anemet@apple.com> | 2017-03-28 20:11:52 +0000 |
---|---|---|
committer | Adam Nemet <anemet@apple.com> | 2017-03-28 20:11:52 +0000 |
commit | cd847a8f3059d87cc6c5343d2dae7b25aacac322 (patch) | |
tree | f36fad6a6759edb3ee14c09c9defdf0e05be25c4 /llvm/unittests/IR/IRBuilderTest.cpp | |
parent | 16af53a3955e8e8b93ccc1d4674e0e5613835961 (diff) | |
download | bcm5719-llvm-cd847a8f3059d87cc6c5343d2dae7b25aacac322.tar.gz bcm5719-llvm-cd847a8f3059d87cc6c5343d2dae7b25aacac322.zip |
[IR] Add AllowContract to FastMathFlags
-ffp-contract=fast does not currently work with LTO because it's passed as a
TargetOption to the backend rather than in the IR. This adds it to
FastMathFlags.
This is toward fixing PR25721
Differential Revision: https://reviews.llvm.org/D31164
llvm-svn: 298939
Diffstat (limited to 'llvm/unittests/IR/IRBuilderTest.cpp')
-rw-r--r-- | llvm/unittests/IR/IRBuilderTest.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/llvm/unittests/IR/IRBuilderTest.cpp b/llvm/unittests/IR/IRBuilderTest.cpp index 5b27fd66360..830ae958769 100644 --- a/llvm/unittests/IR/IRBuilderTest.cpp +++ b/llvm/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); |