]> granicus.if.org Git - llvm/commitdiff
[APInt] Don't call getActiveBits() in ult/ugt(uint64_t) if its a single word.
authorCraig Topper <craig.topper@gmail.com>
Wed, 19 Apr 2017 23:55:48 +0000 (23:55 +0000)
committerCraig Topper <craig.topper@gmail.com>
Wed, 19 Apr 2017 23:55:48 +0000 (23:55 +0000)
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

include/llvm/ADT/APInt.h

index e517a13af1efde4c24550d821004b8b770542b79..1eff4b69b2dc2025f34cc59a51db4fff24eff4ca 100644 (file)
@@ -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