From: Craig Topper Date: Wed, 19 Apr 2017 23:55:48 +0000 (+0000) Subject: [APInt] Don't call getActiveBits() in ult/ugt(uint64_t) if its a single word. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=25d6dbfc6a4e19200410269614813921ff9445af;p=llvm [APInt] Don't call getActiveBits() in ult/ugt(uint64_t) if its a single word. The compiled code already needs to check single/multi word for the countLeadingZeros call inside of getActiveBits, but it isn't able to optimize out the leadingZeros call in the single word case that can't produce a value larger than 64. This shrank the opt binary by about 5-6k on my local x86-64 build. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300798 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/ADT/APInt.h b/include/llvm/ADT/APInt.h index e517a13af1e..1eff4b69b2d 100644 --- a/include/llvm/ADT/APInt.h +++ b/include/llvm/ADT/APInt.h @@ -1083,7 +1083,8 @@ public: /// /// \returns true if *this < RHS when considered unsigned. bool ult(uint64_t RHS) const { - return getActiveBits() > 64 ? false : getZExtValue() < RHS; + // Only need to check active bits if not a single word. + return (isSingleWord() || getActiveBits() <= 64) && getZExtValue() < RHS; } /// \brief Signed less than comparison @@ -1151,7 +1152,8 @@ public: /// /// \returns true if *this > RHS when considered unsigned. bool ugt(uint64_t RHS) const { - return getActiveBits() > 64 ? true : getZExtValue() > RHS; + // Only need to check active bits if not a single word. + return (!isSingleWord() && getActiveBits() > 64) || getZExtValue() > RHS; } /// \brief Signed greather than comparison