Skip to content

Commit

Permalink
[LLVMContextImpl] Separate out integer constant ones
Browse files Browse the repository at this point in the history
  • Loading branch information
aeubanks committed Feb 27, 2023
1 parent c316675 commit 86bdcdf
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions llvm/lib/IR/Constants.cpp
Expand Up @@ -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());
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/IR/LLVMContextImpl.cpp
Expand Up @@ -117,6 +117,7 @@ LLVMContextImpl::~LLVMContextImpl() {
UVConstants.clear();
PVConstants.clear();
IntZeroConstants.clear();
IntOneConstants.clear();
IntConstants.clear();
FPConstants.clear();
CDSConstants.clear();
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/IR/LLVMContextImpl.h
Expand Up @@ -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;

Expand Down

0 comments on commit 86bdcdf

Please sign in to comment.