summaryrefslogtreecommitdiff
path: root/unittests/IR/IRBuilderTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'unittests/IR/IRBuilderTest.cpp')
-rw-r--r--unittests/IR/IRBuilderTest.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/unittests/IR/IRBuilderTest.cpp b/unittests/IR/IRBuilderTest.cpp
index f3db68feacce5..093cbbfc77903 100644
--- a/unittests/IR/IRBuilderTest.cpp
+++ b/unittests/IR/IRBuilderTest.cpp
@@ -130,8 +130,8 @@ TEST_F(IRBuilderTest, GetIntTy) {
TEST_F(IRBuilderTest, FastMathFlags) {
IRBuilder<> Builder(BB);
- Value *F;
- Instruction *FDiv, *FAdd;
+ Value *F, *FC;
+ Instruction *FDiv, *FAdd, *FCmp;
F = Builder.CreateLoad(GV);
F = Builder.CreateFAdd(F, F);
@@ -190,6 +190,24 @@ TEST_F(IRBuilderTest, FastMathFlags) {
Builder.clearFastMathFlags();
+ FC = Builder.CreateFCmpOEQ(F, F);
+ ASSERT_TRUE(isa<Instruction>(FC));
+ FCmp = cast<Instruction>(FC);
+ EXPECT_FALSE(FCmp->hasAllowReciprocal());
+
+ FMF.clear();
+ FMF.setAllowReciprocal();
+ Builder.SetFastMathFlags(FMF);
+
+ FC = Builder.CreateFCmpOEQ(F, F);
+ EXPECT_TRUE(Builder.getFastMathFlags().any());
+ EXPECT_TRUE(Builder.getFastMathFlags().AllowReciprocal);
+ ASSERT_TRUE(isa<Instruction>(FC));
+ FCmp = cast<Instruction>(FC);
+ EXPECT_TRUE(FCmp->hasAllowReciprocal());
+
+ Builder.clearFastMathFlags();
+
// To test a copy, make sure that a '0' and a '1' change state.
F = Builder.CreateFDiv(F, F);
ASSERT_TRUE(isa<Instruction>(F));