~ubuntu-branches/ubuntu/trusty/llvm-toolchain-snapshot/trusty-201310232150

« back to all changes in this revision

Viewing changes to lib/Support/APFloat.cpp

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-27 15:01:57 UTC
  • mfrom: (0.10.1) (0.9.1) (0.8.1) (0.7.1) (0.6.1) (0.5.2)
  • Revision ID: package-import@ubuntu.com-20130527150157-tdkrsjpuvht7v0qx
Tags: 1:3.4~svn182733-1~exp1
* New snapshot release (3.4 release)
* Add a symlink of libLLVM-3.4.so.1 to usr/lib/llvm-3.4/lib/libLLVM-3.4.so
    to fix make the llvm-config-3.4 --libdir work (Closes: #708677)
  * Various packages rename to allow co installations:
    * libclang1 => libclang1-3.4
    * libclang1-dbg => libclang1-3.4-dbg
    * libclang-dev => libclang-3.4-dev
    * libclang-common-dev => libclang-common-3.4-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
872
872
  omsb = APInt::tcMSB(fullSignificand, newPartsCount) + 1;
873
873
  exponent += rhs.exponent;
874
874
 
 
875
  // Assume the operands involved in the multiplication are single-precision
 
876
  // FP, and the two multiplicants are:
 
877
  //   *this = a23 . a22 ... a0 * 2^e1
 
878
  //     rhs = b23 . b22 ... b0 * 2^e2
 
879
  // the result of multiplication is:
 
880
  //   *this = c47 c46 . c45 ... c0 * 2^(e1+e2)
 
881
  // Note that there are two significant bits at the left-hand side of the 
 
882
  // radix point. Move the radix point toward left by one bit, and adjust
 
883
  // exponent accordingly.
 
884
  exponent += 1;
 
885
 
875
886
  if (addend) {
 
887
    // The intermediate result of the multiplication has "2 * precision" 
 
888
    // signicant bit; adjust the addend to be consistent with mul result.
 
889
    //
876
890
    Significand savedSignificand = significand;
877
891
    const fltSemantics *savedSemantics = semantics;
878
892
    fltSemantics extendedSemantics;
880
894
    unsigned int extendedPrecision;
881
895
 
882
896
    /* Normalize our MSB.  */
883
 
    extendedPrecision = precision + precision - 1;
 
897
    extendedPrecision = 2 * precision;
884
898
    if (omsb != extendedPrecision) {
 
899
      assert(extendedPrecision > omsb);
885
900
      APInt::tcShiftLeft(fullSignificand, newPartsCount,
886
901
                         extendedPrecision - omsb);
887
902
      exponent -= extendedPrecision - omsb;
912
927
    omsb = APInt::tcMSB(fullSignificand, newPartsCount) + 1;
913
928
  }
914
929
 
915
 
  exponent -= (precision - 1);
 
930
  // Convert the result having "2 * precision" significant-bits back to the one
 
931
  // having "precision" significant-bits. First, move the radix point from 
 
932
  // poision "2*precision - 1" to "precision - 1". The exponent need to be
 
933
  // adjusted by "2*precision - 1" - "precision - 1" = "precision".
 
934
  exponent -= precision;
916
935
 
 
936
  // In case MSB resides at the left-hand side of radix point, shift the
 
937
  // mantissa right by some amount to make sure the MSB reside right before
 
938
  // the radix point (i.e. "MSB . rest-significant-bits").
 
939
  //
 
940
  // Note that the result is not normalized when "omsb < precision". So, the
 
941
  // caller needs to call APFloat::normalize() if normalized value is expected.
917
942
  if (omsb > precision) {
918
943
    unsigned int bits, significantParts;
919
944
    lostFraction lf;