[PATCH] D39319: Set contract flag when setting unsafe algebra flag
Yichao Yu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 25 22:05:56 PDT 2017
yuyichao created this revision.
I assume this was a oversight in https://reviews.llvm.org/D31164
https://reviews.llvm.org/D39319
Files:
include/llvm/IR/Operator.h
unittests/IR/IRBuilderTest.cpp
Index: unittests/IR/IRBuilderTest.cpp
===================================================================
--- unittests/IR/IRBuilderTest.cpp
+++ unittests/IR/IRBuilderTest.cpp
@@ -227,6 +227,24 @@
Builder.clearFastMathFlags();
+ FC = Builder.CreateFAdd(F, F);
+ EXPECT_FALSE(Builder.getFastMathFlags().any());
+ ASSERT_TRUE(isa<Instruction>(FC));
+ FAdd = cast<Instruction>(FC);
+ EXPECT_FALSE(FAdd->hasNoNaNs());
+ EXPECT_FALSE(FAdd->hasNoInfs());
+ EXPECT_FALSE(FAdd->hasNoSignedZeros());
+ EXPECT_FALSE(FAdd->hasAllowReciprocal());
+ EXPECT_FALSE(FAdd->hasAllowContract());
+ EXPECT_FALSE(FAdd->hasUnsafeAlgebra());
+ FAdd->setHasUnsafeAlgebra(true);
+ EXPECT_TRUE(FAdd->hasNoNaNs());
+ EXPECT_TRUE(FAdd->hasNoInfs());
+ EXPECT_TRUE(FAdd->hasNoSignedZeros());
+ EXPECT_TRUE(FAdd->hasAllowReciprocal());
+ EXPECT_TRUE(FAdd->hasAllowContract());
+ EXPECT_TRUE(FAdd->hasUnsafeAlgebra());
+
// Test a call with FMF.
auto CalleeTy = FunctionType::get(Type::getFloatTy(Ctx),
/*isVarArg=*/false);
Index: include/llvm/IR/Operator.h
===================================================================
--- include/llvm/IR/Operator.h
+++ include/llvm/IR/Operator.h
@@ -232,6 +232,7 @@
setHasNoInfs(true);
setHasNoSignedZeros(true);
setHasAllowReciprocal(true);
+ setHasAllowContract(true);
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39319.120359.patch
Type: text/x-patch
Size: 1389 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171026/e440b570/attachment.bin>
More information about the llvm-commits
mailing list