[llvm-commits] [llvm] r154850 - in /llvm/trunk: 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

Duncan Sands baldrick at free.fr
Mon Apr 16 12:39:33 PDT 2012


Author: baldrick
Date: Mon Apr 16 14:39:33 2012
New Revision: 154850

URL: http://llvm.org/viewvc/llvm-project?rev=154850&view=rev
Log:
Remove support for the special 'fast' value for fpmath accuracy for the moment.

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

Modified: llvm/trunk/docs/LangRef.html
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=154850&r1=154849&r2=154850&view=diff
==============================================================================
--- llvm/trunk/docs/LangRef.html (original)
+++ llvm/trunk/docs/LangRef.html Mon Apr 16 14:39:33 2012
@@ -3008,10 +3008,8 @@
 <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 @@
 </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>
 

Modified: llvm/trunk/include/llvm/Operator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Operator.h?rev=154850&r1=154849&r2=154850&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Operator.h (original)
+++ llvm/trunk/include/llvm/Operator.h Mon Apr 16 14:39:33 2012
@@ -174,13 +174,9 @@
 
   /// \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();

Modified: llvm/trunk/include/llvm/Support/MDBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MDBuilder.h?rev=154850&r1=154849&r2=154850&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/MDBuilder.h (original)
+++ llvm/trunk/include/llvm/Support/MDBuilder.h Mon Apr 16 14:39:33 2012
@@ -26,9 +26,6 @@
   class MDBuilder {
     LLVMContext &Context;
 
-    MDString *getFastString() {
-      return createString("fast");
-    }
   public:
     MDBuilder(LLVMContext &context) : Context(context) {}
 
@@ -41,19 +38,12 @@
     // 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);

Modified: llvm/trunk/lib/VMCore/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=154850&r1=154849&r2=154850&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Instructions.cpp (original)
+++ llvm/trunk/lib/VMCore/Instructions.cpp Mon Apr 16 14:39:33 2012
@@ -2008,35 +2008,14 @@
 
 /// 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();
 }
 
 

Modified: llvm/trunk/lib/VMCore/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=154850&r1=154849&r2=154850&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Verifier.cpp (original)
+++ llvm/trunk/lib/VMCore/Verifier.cpp Mon Apr 16 14:39:33 2012
@@ -1662,8 +1662,6 @@
       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);
     }

Modified: llvm/trunk/test/Verifier/fpmath.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/fpmath.ll?rev=154850&r1=154849&r2=154850&view=diff
==============================================================================
--- llvm/trunk/test/Verifier/fpmath.ll (original)
+++ llvm/trunk/test/Verifier/fpmath.ll Mon Apr 16 14:39:33 2012
@@ -22,16 +22,6 @@
   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 @@
 !4 = metadata !{ float -1.0 }
 !5 = metadata !{ float 0.0 }
 !6 = metadata !{ float 0x7FFFFFFF00000000 }
-!7 = metadata !{ metadata !"fast" }
-!8 = metadata !{ metadata !"slow" }

Modified: llvm/trunk/unittests/Support/MDBuilderTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/MDBuilderTest.cpp?rev=154850&r1=154849&r2=154850&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/MDBuilderTest.cpp (original)
+++ llvm/trunk/unittests/Support/MDBuilderTest.cpp Mon Apr 16 14:39:33 2012
@@ -27,24 +27,12 @@
   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));

Modified: llvm/trunk/unittests/VMCore/InstructionsTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/VMCore/InstructionsTest.cpp?rev=154850&r1=154849&r2=154850&view=diff
==============================================================================
--- llvm/trunk/unittests/VMCore/InstructionsTest.cpp (original)
+++ llvm/trunk/unittests/VMCore/InstructionsTest.cpp Mon Apr 16 14:39:33 2012
@@ -235,19 +235,11 @@
   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;
 }
 





More information about the llvm-commits mailing list