llvm.org GIT mirror
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).
 703 703 return int64_t(X << (64 - B)) >> (64 - B); 704 704 } 705 705 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. 708 708 template 709 709 typename std::enable_if::value, T>::type 710 710 AbsoluteDifference(T X, T Y) { 711 711 return std::max(X, Y) - std::min(X, Y); 712 712 } 713 713 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. 718 717 template 719 718 typename std::enable_if::value, T>::type 720 719 SaturatingAdd(T X, T Y, bool *ResultOverflowed = nullptr) { 729 728 return Z; 730 729 } 731 730 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. 736 734 template 737 735 typename std::enable_if::value, T>::type 738 736 SaturatingMultiply(T X, T Y, bool *ResultOverflowed = nullptr) { 775 773 return Z; 776 774 } 777 775 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. 784 780 template 785 781 typename std::enable_if::value, T>::type 786 782 SaturatingMultiplyAdd(T X, T Y, T A, bool *ResultOverflowed = nullptr) { 794 790 return SaturatingAdd(A, Product, &Overflowed); 795 791 } 796 792 793 /// Use this rather than HUGE_VALF; the latter causes warnings on MSVC. 797 794 extern const float huge_valf; 798 795 } // End llvm namespace 799 796