llvm.org GIT mirror llvm / 61e00f9
Clean up some comments in MathExtras.h. Reviewers: rnk Subscribers: llvm-commits, dylanmckay Differential Revision: https://reviews.llvm.org/D22444 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275721 91177308-0d34-0410-b5e6-96231b3b80d8 Justin Lebar 4 years ago
1 changed file(s) with 13 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
703703 return int64_t(X << (64 - B)) >> (64 - B);
704704 }
705705
706 /// \brief Subtract two unsigned integers, X and Y, of type T and return their
707 /// absolute value.
706 /// Subtract two unsigned integers, X and Y, of type T and return the absolute
707 /// value of the result.
708708 template
709709 typename std::enable_if::value, T>::type
710710 AbsoluteDifference(T X, T Y) {
711711 return std::max(X, Y) - std::min(X, Y);
712712 }
713713
714 /// \brief Add two unsigned integers, X and Y, of type T.
715 /// Clamp the result to the maximum representable value of T on overflow.
716 /// ResultOverflowed indicates if the result is larger than the maximum
717 /// representable value of type T.
714 /// Add two unsigned integers, X and Y, of type T. Clamp the result to the
715 /// maximum representable value of T on overflow. ResultOverflowed indicates if
716 /// the result is larger than the maximum representable value of type T.
718717 template
719718 typename std::enable_if::value, T>::type
720719 SaturatingAdd(T X, T Y, bool *ResultOverflowed = nullptr) {
729728 return Z;
730729 }
731730
732 /// \brief Multiply two unsigned integers, X and Y, of type T.
733 /// Clamp the result to the maximum representable value of T on overflow.
734 /// ResultOverflowed indicates if the result is larger than the maximum
735 /// representable value of type T.
731 /// Multiply two unsigned integers, X and Y, of type T. Clamp the result to the
732 /// maximum representable value of T on overflow. ResultOverflowed indicates if
733 /// the result is larger than the maximum representable value of type T.
736734 template
737735 typename std::enable_if::value, T>::type
738736 SaturatingMultiply(T X, T Y, bool *ResultOverflowed = nullptr) {
775773 return Z;
776774 }
777775
778 /// \brief Multiply two unsigned integers, X and Y, and add the unsigned
779 /// integer, A to the product. Clamp the result to the maximum representable
780 /// value of T on overflow. ResultOverflowed indicates if the result is larger
781 /// than the maximum representable value of type T.
782 /// Note that this is purely a convenience function as there is no distinction
783 /// where overflow occurred in a 'fused' multiply-add for unsigned numbers.
776 /// Multiply two unsigned integers, X and Y, and add the unsigned integer, A to
777 /// the product. Clamp the result to the maximum representable value of T on
778 /// overflow. ResultOverflowed indicates if the result is larger than the
779 /// maximum representable value of type T.
784780 template
785781 typename std::enable_if::value, T>::type
786782 SaturatingMultiplyAdd(T X, T Y, T A, bool *ResultOverflowed = nullptr) {
794790 return SaturatingAdd(A, Product, &Overflowed);
795791 }
796792
793 /// Use this rather than HUGE_VALF; the latter causes warnings on MSVC.
797794 extern const float huge_valf;
798795 } // End llvm namespace
799796