From 86bdcdf00e82865ee7ae3fcbf843a47235851817 Mon Sep 17 00:00:00 2001 From: Arthur Eubanks Date: Thu, 23 Feb 2023 21:47:03 -0800 Subject: [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 --- llvm/lib/IR/Constants.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'llvm/lib/IR/Constants.cpp') diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index 6efc66d..6e25e22 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 &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()); -- cgit v1.1