diff options
author | Arthur Eubanks <aeubanks@google.com> | 2023-02-23 21:16:27 -0800 |
---|---|---|
committer | Arthur Eubanks <aeubanks@google.com> | 2023-02-27 10:18:39 -0800 |
commit | c31667539bc6bf6c7d56c88f216291b1d9a203b9 (patch) | |
tree | 8aedbef7ef4c6df75470157b97b0c0761242fea6 /llvm/lib/IR/Constants.cpp | |
parent | 007177bdde60a822ccaefc96593e818c2235e2d5 (diff) | |
download | llvm-c31667539bc6bf6c7d56c88f216291b1d9a203b9.zip llvm-c31667539bc6bf6c7d56c88f216291b1d9a203b9.tar.gz llvm-c31667539bc6bf6c7d56c88f216291b1d9a203b9.tar.bz2 |
[LLVMContextImpl] Separate out integer constant zeroes
Very small compile time improvement:
https://llvm-compile-time-tracker.com/compare.php?from=a628ca4925f7249b4fbd3e932c9627b12e2770dd&to=6a7a8907e8334eaf551742148079c628f78e6ed7&stat=instructions:u
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D144745
Diffstat (limited to 'llvm/lib/IR/Constants.cpp')
-rw-r--r-- | llvm/lib/IR/Constants.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index a536711..6efc66d 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -874,7 +874,9 @@ Constant *ConstantInt::getBool(Type *Ty, bool V) { 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 = pImpl->IntConstants[V]; + std::unique_ptr<ConstantInt> &Slot = + V.isZero() ? pImpl->IntZeroConstants[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()); |