aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2012-04-16 19:39:33 +0000
committerDuncan Sands <baldrick@free.fr>2012-04-16 19:39:33 +0000
commit2867c85a3754320f96e36afb63325bb76269caa4 (patch)
treec5bd58459f230d669f87a597c75213ab42b9529d
parent2c651fe6f445724627dcc48064797dca2aa4aedc (diff)
downloadexternal_llvm-2867c85a3754320f96e36afb63325bb76269caa4.zip
external_llvm-2867c85a3754320f96e36afb63325bb76269caa4.tar.gz
external_llvm-2867c85a3754320f96e36afb63325bb76269caa4.tar.bz2
Remove support for the special 'fast' value for fpmath accuracy for the moment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154850 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--docs/LangRef.html10
-rw-r--r--include/llvm/Operator.h6
-rw-r--r--include/llvm/Support/MDBuilder.h16
-rw-r--r--lib/VMCore/Instructions.cpp27
-rw-r--r--lib/VMCore/Verifier.cpp2
-rw-r--r--test/Verifier/fpmath.ll12
-rw-r--r--unittests/Support/MDBuilderTest.cpp12
-rw-r--r--unittests/VMCore/InstructionsTest.cpp8
8 files changed, 10 insertions, 83 deletions
diff --git a/docs/LangRef.html b/docs/LangRef.html
index 3a474a5..9989cc8 100644
--- a/docs/LangRef.html
+++ b/docs/LangRef.html
@@ -3008,10 +3008,8 @@ call void @llvm.dbg.value(metadata !24, i64 0, metadata !25)
<p><tt>fpmath</tt> metadata may be attached to any instruction of floating point
type. It can be used to express the maximum acceptable error in the result of
that instruction, in ULPs, thus potentially allowing the compiler to use a
- more efficient but less accurate method of computing it. The number of ULPs
- may also be the string <tt>"fast"</tt>, which tells the compiler that speed
- matters more than accuracy, so any fairly accurate method of computation is
- fine as long as it is quick. ULP is defined as follows:</p>
+ more efficient but less accurate method of computing it. ULP is defined as
+ follows:</p>
<blockquote>
@@ -3024,13 +3022,11 @@ call void @llvm.dbg.value(metadata !24, i64 0, metadata !25)
</blockquote>
<p>The metadata node shall consist of a single positive floating point number
- representing the maximum relative error, or the string <tt>"fast"</tt>.
- For example:</p>
+ representing the maximum relative error, for example:</p>
<div class="doc_code">
<pre>
!0 = metadata !{ float 2.5 } ; maximum acceptable inaccuracy is 2.5 ULPs
-!1 = metadata !{ !metadata !"fast" } ; potentially unbounded inaccuracy
</pre>
</div>
diff --git a/include/llvm/Operator.h b/include/llvm/Operator.h
index 6bd7e56..1e86980 100644
--- a/include/llvm/Operator.h
+++ b/include/llvm/Operator.h
@@ -174,13 +174,9 @@ public:
/// \brief Get the maximum error permitted by this operation in ULPs. An
/// accuracy of 0.0 means that the operation should be performed with the
- /// default precision. A huge value is returned if the accuracy is 'fast'.
+ /// default precision.
float getFPAccuracy() const;
- /// \brief Return true if the accuracy is 'fast'. This indicates that speed
- /// is more important than accuracy.
- bool isFastFPAccuracy() const;
-
static inline bool classof(const FPMathOperator *) { return true; }
static inline bool classof(const Instruction *I) {
return I->getType()->isFPOrFPVectorTy();
diff --git a/include/llvm/Support/MDBuilder.h b/include/llvm/Support/MDBuilder.h
index f6d8452..40f028a 100644
--- a/include/llvm/Support/MDBuilder.h
+++ b/include/llvm/Support/MDBuilder.h
@@ -26,9 +26,6 @@ namespace llvm {
class MDBuilder {
LLVMContext &Context;
- MDString *getFastString() {
- return createString("fast");
- }
public:
MDBuilder(LLVMContext &context) : Context(context) {}
@@ -41,19 +38,12 @@ namespace llvm {
// FPMath metadata.
//===------------------------------------------------------------------===//
- /// \brief Return metadata with appropriate settings for 'fast math'.
- MDNode *createFastFPMath() {
- return MDNode::get(Context, getFastString());
- }
-
- /// \brief Return metadata with the given settings. Special values for the
- /// Accuracy parameter are 0.0, which means the default (maximal precision)
- /// setting; and negative values which all mean 'fast'.
+ /// \brief Return metadata with the given settings. The special value 0.0
+ /// for the Accuracy parameter indicates the default (maximal precision)
+ /// setting.
MDNode *createFPMath(float Accuracy) {
if (Accuracy == 0.0)
return 0;
- if (Accuracy < 0.0)
- return MDNode::get(Context, getFastString());
assert(Accuracy > 0.0 && "Invalid fpmath accuracy!");
Value *Op = ConstantFP::get(Type::getFloatTy(Context), Accuracy);
return MDNode::get(Context, Op);
diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp
index 185cd05..6c5db32 100644
--- a/lib/VMCore/Instructions.cpp
+++ b/lib/VMCore/Instructions.cpp
@@ -2008,35 +2008,14 @@ bool BinaryOperator::isExact() const {
/// getFPAccuracy - Get the maximum error permitted by this operation in ULPs.
/// An accuracy of 0.0 means that the operation should be performed with the
-/// default precision. A huge value is returned if the accuracy is 'fast'.
+/// default precision.
float FPMathOperator::getFPAccuracy() const {
const MDNode *MD =
cast<Instruction>(this)->getMetadata(LLVMContext::MD_fpmath);
if (!MD)
return 0.0;
- Value *Op = MD->getOperand(0);
- if (const ConstantFP *Accuracy = dyn_cast<ConstantFP>(Op))
- return Accuracy->getValueAPF().convertToFloat();
- // If it's not a floating point number then it must be 'fast'.
- assert(isa<MDString>(Op) && cast<MDString>(Op)->getString() == "fast" &&
- "Expected the 'fast' keyword!");
- return HUGE_VALF;
-}
-
-/// isFastFPAccuracy - Return true if the accuracy is 'fast'. This says that
-/// speed is more important than accuracy.
-bool FPMathOperator::isFastFPAccuracy() const {
- const MDNode *MD =
- cast<Instruction>(this)->getMetadata(LLVMContext::MD_fpmath);
- if (!MD)
- return false;
- Value *Op = MD->getOperand(0);
- if (isa<ConstantFP>(Op))
- return false;
- // If it's not a floating point number then it must be 'fast'.
- assert(isa<MDString>(Op) && cast<MDString>(Op)->getString() == "fast" &&
- "Expected the 'fast' keyword!");
- return true;
+ ConstantFP *Accuracy = cast<ConstantFP>(MD->getOperand(0));
+ return Accuracy->getValueAPF().convertToFloat();
}
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp
index 2576766..47baef3 100644
--- a/lib/VMCore/Verifier.cpp
+++ b/lib/VMCore/Verifier.cpp
@@ -1662,8 +1662,6 @@ void Verifier::visitInstruction(Instruction &I) {
APFloat Accuracy = CFP0->getValueAPF();
Assert1(Accuracy.isNormal() && !Accuracy.isNegative(),
"fpmath accuracy not a positive number!", &I);
- } else if (MDString *S0 = dyn_cast_or_null<MDString>(Op0)) {
- Assert1(S0->getString() == "fast", "wrong fpmath accuracy keyword!", &I);
} else {
Assert1(false, "invalid fpmath accuracy!", &I);
}
diff --git a/test/Verifier/fpmath.ll b/test/Verifier/fpmath.ll
index a7d3ea8..b764a63 100644
--- a/test/Verifier/fpmath.ll
+++ b/test/Verifier/fpmath.ll
@@ -22,16 +22,6 @@ define void @fpmath1(i32 %i, float %f, <2 x float> %g) {
ret void
}
-define void @fpmath2(float %f, <2 x float> %g) {
- %w = fadd float %f, %f, !fpmath !7
-; Above line is correct.
- %w2 = fadd <2 x float> %g, %g, !fpmath !7
-; Above line is correct.
- %x = fadd float %f, %f, !fpmath !8
-; CHECK: wrong fpmath accuracy keyword!
- ret void
-}
-
!0 = metadata !{ float 1.0 }
!1 = metadata !{ }
!2 = metadata !{ float 1.0, float 1.0 }
@@ -39,5 +29,3 @@ define void @fpmath2(float %f, <2 x float> %g) {
!4 = metadata !{ float -1.0 }
!5 = metadata !{ float 0.0 }
!6 = metadata !{ float 0x7FFFFFFF00000000 }
-!7 = metadata !{ metadata !"fast" }
-!8 = metadata !{ metadata !"slow" }
diff --git a/unittests/Support/MDBuilderTest.cpp b/unittests/Support/MDBuilderTest.cpp
index e8e0386..d54c7e8 100644
--- a/unittests/Support/MDBuilderTest.cpp
+++ b/unittests/Support/MDBuilderTest.cpp
@@ -27,24 +27,12 @@ TEST_F(MDBuilderTest, createString) {
EXPECT_EQ(Str0->getString(), StringRef(""));
EXPECT_EQ(Str1->getString(), StringRef("string"));
}
-TEST_F(MDBuilderTest, createFastFPMath) {
- MDBuilder MDHelper(Context);
- MDNode *MD = MDHelper.createFastFPMath();
- EXPECT_NE(MD, (MDNode *)0);
- EXPECT_EQ(MD->getNumOperands(), 1U);
- Value *Op = MD->getOperand(0);
- EXPECT_TRUE(isa<MDString>(Op));
- EXPECT_EQ(cast<MDString>(Op)->getString(), "fast");
-}
TEST_F(MDBuilderTest, createFPMath) {
MDBuilder MDHelper(Context);
MDNode *MD0 = MDHelper.createFPMath(0.0);
MDNode *MD1 = MDHelper.createFPMath(1.0);
- MDNode *MDF = MDHelper.createFPMath(-1.0);
- MDNode *MDF2 = MDHelper.createFastFPMath();
EXPECT_EQ(MD0, (MDNode *)0);
EXPECT_NE(MD1, (MDNode *)0);
- EXPECT_EQ(MDF, MDF2);
EXPECT_EQ(MD1->getNumOperands(), 1U);
Value *Op = MD1->getOperand(0);
EXPECT_TRUE(isa<ConstantFP>(Op));
diff --git a/unittests/VMCore/InstructionsTest.cpp b/unittests/VMCore/InstructionsTest.cpp
index 9c0cb44..d002101 100644
--- a/unittests/VMCore/InstructionsTest.cpp
+++ b/unittests/VMCore/InstructionsTest.cpp
@@ -235,19 +235,11 @@ TEST(InstructionsTest, FPMathOperator) {
MDBuilder MDHelper(Context);
Instruction *I = Builder.CreatePHI(Builder.getDoubleTy(), 0);
MDNode *MD1 = MDHelper.createFPMath(1.0);
- MDNode *MDF = MDHelper.createFastFPMath();
Value *V1 = Builder.CreateFAdd(I, I, "", MD1);
- Value *VF = Builder.CreateFAdd(I, I, "", MDF);
EXPECT_TRUE(isa<FPMathOperator>(V1));
- EXPECT_TRUE(isa<FPMathOperator>(VF));
FPMathOperator *O1 = cast<FPMathOperator>(V1);
- FPMathOperator *OF = cast<FPMathOperator>(VF);
- EXPECT_FALSE(O1->isFastFPAccuracy());
- EXPECT_TRUE(OF->isFastFPAccuracy());
EXPECT_EQ(O1->getFPAccuracy(), 1.0);
- EXPECT_GT(OF->getFPAccuracy(), 999.0);
delete V1;
- delete VF;
delete I;
}