[llvm] r300824 - [APInt] In slt/sgt(uint64_t), only call getMinSignedBits if the APInt is not a single word.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 19 23:04:03 PDT 2017


Author: ctopper
Date: Thu Apr 20 01:04:03 2017
New Revision: 300824

URL: http://llvm.org/viewvc/llvm-project?rev=300824&view=rev
Log:
[APInt] In slt/sgt(uint64_t), only call getMinSignedBits if the APInt is not a single word.

Modified:
    llvm/trunk/include/llvm/ADT/APInt.h

Modified: llvm/trunk/include/llvm/ADT/APInt.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/APInt.h?rev=300824&r1=300823&r2=300824&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/APInt.h (original)
+++ llvm/trunk/include/llvm/ADT/APInt.h Thu Apr 20 01:04:03 2017
@@ -1104,7 +1104,8 @@ public:
   ///
   /// \returns true if *this < RHS when considered signed.
   bool slt(int64_t RHS) const {
-    return getMinSignedBits() > 64 ? isNegative() : getSExtValue() < RHS;
+    return (!isSingleWord() && getMinSignedBits() > 64) ? isNegative()
+                                                        : getSExtValue() < RHS;
   }
 
   /// \brief Unsigned less or equal comparison
@@ -1173,7 +1174,8 @@ public:
   ///
   /// \returns true if *this > RHS when considered signed.
   bool sgt(int64_t RHS) const {
-    return getMinSignedBits() > 64 ? !isNegative() : getSExtValue() > RHS;
+    return (!isSingleWord() && getMinSignedBits() > 64) ? !isNegative()
+                                                        : getSExtValue() > RHS;
   }
 
   /// \brief Unsigned greater or equal comparison




More information about the llvm-commits mailing list