llvm.org GIT mirror llvm / 0262597
[APInt] No need for a copy when taking min/max of an APInt. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260827 91177308-0d34-0410-b5e6-96231b3b80d8 Benjamin Kramer 4 years ago
1 changed file(s) with 12 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
17431743 namespace APIntOps {
17441744
17451745 /// \brief Determine the smaller of two APInts considered to be signed.
1746 inline APInt smin(const APInt &A, const APInt &B) { return A.slt(B) ? A : B; }
1746 inline const APInt &smin(const APInt &A, const APInt &B) {
1747 return A.slt(B) ? A : B;
1748 }
17471749
17481750 /// \brief Determine the larger of two APInts considered to be signed.
1749 inline APInt smax(const APInt &A, const APInt &B) { return A.sgt(B) ? A : B; }
1751 inline const APInt &smax(const APInt &A, const APInt &B) {
1752 return A.sgt(B) ? A : B;
1753 }
17501754
17511755 /// \brief Determine the smaller of two APInts considered to be signed.
1752 inline APInt umin(const APInt &A, const APInt &B) { return A.ult(B) ? A : B; }
1756 inline const APInt &umin(const APInt &A, const APInt &B) {
1757 return A.ult(B) ? A : B;
1758 }
17531759
17541760 /// \brief Determine the larger of two APInts considered to be unsigned.
1755 inline APInt umax(const APInt &A, const APInt &B) { return A.ugt(B) ? A : B; }
1761 inline const APInt &umax(const APInt &A, const APInt &B) {
1762 return A.ugt(B) ? A : B;
1763 }
17561764
17571765 /// \brief Check if the specified APInt has a N-bits unsigned integer value.
17581766 inline bool isIntN(unsigned N, const APInt &APIVal) { return APIVal.isIntN(N); }