[all-commits] [llvm/llvm-project] 427e20: [APInt] improve initialization performance (#106945)

Princeton Ferro via All-commits all-commits at lists.llvm.org
Tue Sep 3 23:54:58 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 427e202a401514cb28bf2ca621baae8e1b2f552f
      https://github.com/llvm/llvm-project/commit/427e202a401514cb28bf2ca621baae8e1b2f552f
  Author: Princeton Ferro <princetonferro at gmail.com>
  Date:   2024-09-04 (Wed, 04 Sep 2024)

  Changed paths:
    M llvm/lib/Support/APInt.cpp

  Log Message:
  -----------
  [APInt] improve initialization performance (#106945)

The purpose is to save an extra memset in both cases:

1. When `int64_t(val) < 0`, zeroing out is redundant as the subsequent
for-loop will initialize to `val .. 0xFFFFF ....`. Instead we should
only create an uninitialized buffer, and transform the slow for-loop
into a memset to initialize the higher words to `0xFF`.
2. In the other case, first we create an uninitialized array (`new
int64_t[]`) and _then_ we zero it out with `memset`. But this can be
combined in one operation with `new int64_t[]()`, which
default-initializes the array.

On one example where use of APInt was heavy, this improved compile time
by 1%.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list