[PATCH] D30486: [APInt] Optimize APInt creation from uint64_t

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 1 13:18:17 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL296677: [APInt] Optimize APInt creation from uint64_t (authored by ctopper).

Changed prior to commit:
  https://reviews.llvm.org/D30486?vs=90125&id=90222#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30486

Files:
  llvm/trunk/include/llvm/ADT/APInt.h
  llvm/trunk/lib/Support/APInt.cpp


Index: llvm/trunk/lib/Support/APInt.cpp
===================================================================
--- llvm/trunk/lib/Support/APInt.cpp
+++ llvm/trunk/lib/Support/APInt.cpp
@@ -81,6 +81,7 @@
   if (isSigned && int64_t(val) < 0)
     for (unsigned i = 1; i < getNumWords(); ++i)
       pVal[i] = -1ULL;
+  clearUnusedBits();
 }
 
 void APInt::initSlowCase(const APInt& that) {
Index: llvm/trunk/include/llvm/ADT/APInt.h
===================================================================
--- llvm/trunk/include/llvm/ADT/APInt.h
+++ llvm/trunk/include/llvm/ADT/APInt.h
@@ -240,11 +240,12 @@
   APInt(unsigned numBits, uint64_t val, bool isSigned = false)
       : BitWidth(numBits), VAL(0) {
     assert(BitWidth && "bitwidth too small");
-    if (isSingleWord())
+    if (isSingleWord()) {
       VAL = val;
-    else
+      clearUnusedBits();
+    } else {
       initSlowCase(val, isSigned);
-    clearUnusedBits();
+    }
   }
 
   /// \brief Construct an APInt of numBits width, initialized as bigVal[].


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30486.90222.patch
Type: text/x-patch
Size: 1016 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170301/3e53e8ee/attachment.bin>


More information about the llvm-commits mailing list