[llvm] 86bdcdf - [LLVMContextImpl] Separate out integer constant ones
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 27 10:18:57 PST 2023
Author: Arthur Eubanks
Date: 2023-02-27T10:18:39-08:00
New Revision: 86bdcdf00e82865ee7ae3fcbf843a47235851817
URL: https://github.com/llvm/llvm-project/commit/86bdcdf00e82865ee7ae3fcbf843a47235851817
DIFF: https://github.com/llvm/llvm-project/commit/86bdcdf00e82865ee7ae3fcbf843a47235851817.diff
LOG: [LLVMContextImpl] Separate out integer constant ones
Very small compile time improvement:
https://llvm-compile-time-tracker.com/compare.php?from=6a7a8907e8334eaf551742148079c628f78e6ed7&to=454d1181fbdb9121f0c7a3ecf526520db32ab420&stat=instructions:u
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D144746
Added:
Modified:
llvm/lib/IR/Constants.cpp
llvm/lib/IR/LLVMContextImpl.cpp
llvm/lib/IR/LLVMContextImpl.h
Removed:
################################################################################
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp
index 6efc66d0983c7..6e25e224b1dbc 100644
--- a/llvm/lib/IR/Constants.cpp
+++ b/llvm/lib/IR/Constants.cpp
@@ -875,8 +875,9 @@ ConstantInt *ConstantInt::get(LLVMContext &Context, const APInt &V) {
// 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());
diff --git a/llvm/lib/IR/LLVMContextImpl.cpp b/llvm/lib/IR/LLVMContextImpl.cpp
index 98157e6a8fa59..c076ee0a0a728 100644
--- a/llvm/lib/IR/LLVMContextImpl.cpp
+++ b/llvm/lib/IR/LLVMContextImpl.cpp
@@ -117,6 +117,7 @@ LLVMContextImpl::~LLVMContextImpl() {
UVConstants.clear();
PVConstants.clear();
IntZeroConstants.clear();
+ IntOneConstants.clear();
IntConstants.clear();
FPConstants.clear();
CDSConstants.clear();
diff --git a/llvm/lib/IR/LLVMContextImpl.h b/llvm/lib/IR/LLVMContextImpl.h
index f828ea9c69f9b..7d6c65ab2a21e 100644
--- a/llvm/lib/IR/LLVMContextImpl.h
+++ b/llvm/lib/IR/LLVMContextImpl.h
@@ -1447,6 +1447,7 @@ class LLVMContextImpl {
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;
More information about the llvm-commits
mailing list