Remove roundingMode argument in APFloat::mod
authorStephen Canon <scanon@apple.com>
Mon, 21 Sep 2015 19:29:25 +0000 (19:29 +0000)
committerStephen Canon <scanon@apple.com>
Mon, 21 Sep 2015 19:29:25 +0000 (19:29 +0000)
Because mod is always exact, this function should have never taken a rounding mode argument.  The actual implementation still has issues, which I'll look at resolving in a subsequent patch.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@248195 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/APFloat.h
lib/CodeGen/SelectionDAG/SelectionDAG.cpp
lib/ExecutionEngine/ExecutionEngine.cpp
lib/IR/ConstantFold.cpp
lib/Support/APFloat.cpp

index bc7335e5b73a09068e249af6362f0d63a5fc1299..5984749ea9ab8d0519adb7c4ac05eaec7db9fad0 100644 (file)
@@ -299,7 +299,7 @@ public:
   /// IEEE remainder.
   opStatus remainder(const APFloat &);
   /// C fmod, or llvm frem.
-  opStatus mod(const APFloat &, roundingMode);
+  opStatus mod(const APFloat &);
   opStatus fusedMultiplyAdd(const APFloat &, const APFloat &, roundingMode);
   opStatus roundToIntegral(roundingMode);
   /// IEEE-754R 5.3.1: nextUp/nextDown.
index 2aec9050d9720c6491318b3b810177f7cf863fe1..a968e965a0d9b59cf123e0725348a68202464c0b 100644 (file)
@@ -3738,7 +3738,7 @@ SDValue SelectionDAG::getNode(unsigned Opcode, SDLoc DL, EVT VT, SDValue N1,
         }
         break;
       case ISD::FREM :
-        s = V1.mod(V2, APFloat::rmNearestTiesToEven);
+        s = V1.mod(V2);
         if (!HasFPExceptions || (s!=APFloat::opInvalidOp &&
                                  s!=APFloat::opDivByZero)) {
           return getConstantFP(V1, DL, VT);
index 136a2d5f03790ee9fb2766cf7950938f97146310..cd62525122c08b345fc0a125fa5e41b715d23676 100644 (file)
@@ -869,8 +869,7 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
             GV.IntVal = apfLHS.bitcastToAPInt();
             break;
           case Instruction::FRem:
-            apfLHS.mod(APFloat(Sem, RHS.IntVal),
-                       APFloat::rmNearestTiesToEven);
+            apfLHS.mod(APFloat(Sem, RHS.IntVal));
             GV.IntVal = apfLHS.bitcastToAPInt();
             break;
           }
index 1d2f4b2c20393fc36fe9e0b71d669e50de0139a2..68ddf096754733cd6d308cc1807471c086731609 100644 (file)
@@ -1187,7 +1187,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode,
         (void)C3V.divide(C2V, APFloat::rmNearestTiesToEven);
         return ConstantFP::get(C1->getContext(), C3V);
       case Instruction::FRem:
-        (void)C3V.mod(C2V, APFloat::rmNearestTiesToEven);
+        (void)C3V.mod(C2V);
         return ConstantFP::get(C1->getContext(), C3V);
       }
     }
index 6bcc053d467a1b4653dc82b60bd3123226fed5da..91b3db59d0e3d82e02271a07acf2339c1b6f1087 100644 (file)
@@ -1771,7 +1771,7 @@ APFloat::remainder(const APFloat &rhs)
 /* Normalized llvm frem (C fmod).
    This is not currently correct in all cases.  */
 APFloat::opStatus
-APFloat::mod(const APFloat &rhs, roundingMode rounding_mode)
+APFloat::mod(const APFloat &rhs)
 {
   opStatus fs;
   fs = modSpecials(rhs);
@@ -1796,10 +1796,10 @@ APFloat::mod(const APFloat &rhs, roundingMode rounding_mode)
                                           rmNearestTiesToEven);
     assert(fs==opOK);   // should always work
 
-    fs = V.multiply(rhs, rounding_mode);
+    fs = V.multiply(rhs, rmNearestTiesToEven);
     assert(fs==opOK || fs==opInexact);   // should not overflow or underflow
 
-    fs = subtract(V, rounding_mode);
+    fs = subtract(V, rmNearestTiesToEven);
     assert(fs==opOK || fs==opInexact);   // likewise
 
     if (isZero())