[llvm-commits] [llvm] r168943 - in /llvm/trunk: include/llvm/Instruction.h lib/VMCore/Instruction.cpp unittests/VMCore/IRBuilderTest.cpp
Michael Ilseman
milseman at apple.com
Thu Nov 29 13:25:12 PST 2012
Author: milseman
Date: Thu Nov 29 15:25:12 2012
New Revision: 168943
URL: http://llvm.org/viewvc/llvm-project?rev=168943&view=rev
Log:
copyFastMathFlags utility and test case
Modified:
llvm/trunk/include/llvm/Instruction.h
llvm/trunk/lib/VMCore/Instruction.cpp
llvm/trunk/unittests/VMCore/IRBuilderTest.cpp
Modified: llvm/trunk/include/llvm/Instruction.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instruction.h?rev=168943&r1=168942&r2=168943&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Instruction.h (original)
+++ llvm/trunk/include/llvm/Instruction.h Thu Nov 29 15:25:12 2012
@@ -227,6 +227,9 @@
/// these flats.
FastMathFlags getFastMathFlags() const;
+ /// Copy I's fast-math flags
+ void copyFastMathFlags(const Instruction *I);
+
private:
/// hasMetadataHashEntry - Return true if we have an entry in the on-the-side
/// metadata hash.
Modified: llvm/trunk/lib/VMCore/Instruction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instruction.cpp?rev=168943&r1=168942&r2=168943&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Instruction.cpp (original)
+++ llvm/trunk/lib/VMCore/Instruction.cpp Thu Nov 29 15:25:12 2012
@@ -177,6 +177,12 @@
return cast<FPMathOperator>(this)->getFastMathFlags();
}
+/// Copy I's fast-math flags
+void Instruction::copyFastMathFlags(const Instruction *I) {
+ setFastMathFlags(I->getFastMathFlags());
+}
+
+
const char *Instruction::getOpcodeName(unsigned OpCode) {
switch (OpCode) {
// Terminators
Modified: llvm/trunk/unittests/VMCore/IRBuilderTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/VMCore/IRBuilderTest.cpp?rev=168943&r1=168942&r2=168943&view=diff
==============================================================================
--- llvm/trunk/unittests/VMCore/IRBuilderTest.cpp (original)
+++ llvm/trunk/unittests/VMCore/IRBuilderTest.cpp Thu Nov 29 15:25:12 2012
@@ -164,6 +164,15 @@
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->getFastMathFlags().any());
+ FDiv->copyFastMathFlags(FAdd);
+ EXPECT_TRUE(FDiv->hasNoNaNs());
+
}
}
More information about the llvm-commits
mailing list