[PATCH] D144746: [LLVMContextImpl] Separate out integer constant ones

Arthur Eubanks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 24 09:49:12 PST 2023


aeubanks created this revision.
aeubanks added reviewers: asbirlea, nikic.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
aeubanks requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Very small compile time improvement:
https://llvm-compile-time-tracker.com/compare.php?from=6a7a8907e8334eaf551742148079c628f78e6ed7&to=454d1181fbdb9121f0c7a3ecf526520db32ab420&stat=instructions:u


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144746

Files:
  llvm/lib/IR/Constants.cpp
  llvm/lib/IR/LLVMContextImpl.cpp
  llvm/lib/IR/LLVMContextImpl.h


Index: llvm/lib/IR/LLVMContextImpl.h
===================================================================
--- llvm/lib/IR/LLVMContextImpl.h
+++ llvm/lib/IR/LLVMContextImpl.h
@@ -1447,6 +1447,7 @@
   DenseMap<const Value *, ValueName *> ValueNames;
 
   DenseMap<unsigned, std::unique_ptr<ConstantInt>> IntZeroConstants;
+  DenseMap<unsigned, std::unique_ptr<ConstantInt>> IntOneConstants;
   DenseMap<APInt, std::unique_ptr<ConstantInt>, DenseMapAPIntKeyInfo>
       IntConstants;
 
Index: llvm/lib/IR/LLVMContextImpl.cpp
===================================================================
--- llvm/lib/IR/LLVMContextImpl.cpp
+++ llvm/lib/IR/LLVMContextImpl.cpp
@@ -117,6 +117,7 @@
   UVConstants.clear();
   PVConstants.clear();
   IntZeroConstants.clear();
+  IntOneConstants.clear();
   IntConstants.clear();
   FPConstants.clear();
   CDSConstants.clear();
Index: llvm/lib/IR/Constants.cpp
===================================================================
--- llvm/lib/IR/Constants.cpp
+++ llvm/lib/IR/Constants.cpp
@@ -875,8 +875,9 @@
   // get an existing value or the insertion position
   LLVMContextImpl *pImpl = Context.pImpl;
   std::unique_ptr<ConstantInt> &Slot =
-      V.isZero() ? pImpl->IntZeroConstants[V.getBitWidth()]
-                 : pImpl->IntConstants[V];
+      V.isZero()  ? pImpl->IntZeroConstants[V.getBitWidth()]
+      : V.isOne() ? pImpl->IntOneConstants[V.getBitWidth()]
+                  : pImpl->IntConstants[V];
   if (!Slot) {
     // Get the corresponding integer type for the bit width of the value.
     IntegerType *ITy = IntegerType::get(Context, V.getBitWidth());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144746.500243.patch
Type: text/x-patch
Size: 1610 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230224/93b3b8ff/attachment.bin>


More information about the llvm-commits mailing list