Remove support for the special 'fast' value for fpmath accuracy for the moment.
authorDuncan Sands <baldrick@free.fr>
Mon, 16 Apr 2012 19:39:33 +0000 (19:39 +0000)
committerDuncan Sands <baldrick@free.fr>
Mon, 16 Apr 2012 19:39:33 +0000 (19:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154850 91177308-0d34-0410-b5e6-96231b3b80d8

docs/LangRef.html
include/llvm/Operator.h
include/llvm/Support/MDBuilder.h
lib/VMCore/Instructions.cpp
lib/VMCore/Verifier.cpp
test/Verifier/fpmath.ll
unittests/Support/MDBuilderTest.cpp
unittests/VMCore/InstructionsTest.cpp

index 3a474a554d4c5de0151f7aeec055c976a44d81ec..9989cc819716a7147ff6ce87e4e34f9d49fa074f 100644 (file)
@@ -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>
 
index 6bd7e56607584a484cc136cc90d497b8466da94e..1e86980cf303fa5b59956aa60e2acb4ceded5cf8 100644 (file)
@@ -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();
index f6d84526ab2644dd5f88768a52ba1863c4c65564..40f028a432749a970d328a62e43836cc43441141 100644 (file)
@@ -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);
index 185cd0557c17e4f967aeeae7922b1d160a571173..6c5db3287641b279cba07b9e2c910cf0b04d3d1f 100644 (file)
@@ -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();
 }
 
 
index 2576766928ce5bc756a2091b34bbc1bb7db7b060..47baef3e29df62565160089fddadaebdc28f0360 100644 (file)
@@ -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);
     }
index a7d3ea8e8988e5b289590314439391a4a357ce59..b764a63f0a4aacdc627090c2de39365ee49ca70a 100644 (file)
@@ -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" }
index e8e0386dac673eb764033aaaee318c40297ba3e7..d54c7e8e8d7134bba185420cbf23e9ee69053a29 100644 (file)
@@ -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));
index 9c0cb4409f752c847448a68d1921a2f674207f24..d002101cd3b9ad941189aff19daedec08b6c44d7 100644 (file)
@@ -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;
 }