History log of /llvm-project/llvm/lib/Support/APInt.cpp (Results 1 – 25 of 434)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: llvmorg-21-init
# 63b0ab84 17-Jan-2025 Iman Hosseini <imanhosseini@google.com>

remove extra ; (#123352)

Remove erroneous extra semicolon in:
https://github.com/llvm/llvm-project/pull/122788

Co-authored-by: ImanHosseini <imanhosseini.17@gmail.com>


# 8ae1cb2b 17-Jan-2025 Iman Hosseini <imanhosseini@google.com>

add power function to APInt (#122788)

I am trying to calculate power function for APFloat, APInt to constant
fold vector reductions: https://github.com/llvm/llvm-project/pull/122450
I need this util

add power function to APInt (#122788)

I am trying to calculate power function for APFloat, APInt to constant
fold vector reductions: https://github.com/llvm/llvm-project/pull/122450
I need this utility to fold N `mul`s into power.

---------

Co-authored-by: ImanHosseini <imanhosseini.17@gmail.com>
Co-authored-by: Jakub Kuderski <kubakuderski@gmail.com>

show more ...


Revision tags: llvmorg-19.1.7, llvmorg-19.1.6, llvmorg-19.1.5, llvmorg-19.1.4, llvmorg-19.1.3
# 83953c7d 15-Oct-2024 NAKAMURA Takumi <geek4civic@gmail.com>

APInt.cpp: Prune a stray semicolon.


Revision tags: llvmorg-19.1.2
# bcb15d00 05-Oct-2024 Craig Topper <craig.topper@sifive.com>

[APInt] Slightly simplify APInt::ashrSlowCase. NFC (#111220)

Use an arithmetic shift for the last word copy when BitShift!=0. This
avoids an explicit sign extend after the shift.


Revision tags: llvmorg-19.1.1, llvmorg-19.1.0
# 427e202a 04-Sep-2024 Princeton Ferro <princetonferro@gmail.com>

[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 in

[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%.

show more ...


Revision tags: llvmorg-19.1.0-rc4
# 30cc198c 02-Sep-2024 Nikita Popov <npopov@redhat.com>

[APInt] Add default-disabled assertion to APInt constructor (#106524)

If the uint64_t constructor is used, assert that the value is actually a
signed or unsigned N-bit integer depending on whether

[APInt] Add default-disabled assertion to APInt constructor (#106524)

If the uint64_t constructor is used, assert that the value is actually a
signed or unsigned N-bit integer depending on whether the isSigned flag
is set. Provide an implicitTrunc flag to restore the previous behavior,
where the argument is silently truncated instead.

In this commit, implicitTrunc is enabled by default, which means that
the new assertions are disabled and no actual change in behavior occurs.
The plan is to flip the default once all places violating the assertion
have been fixed. See #80309 for the scope of the necessary changes.

The primary motivation for this change is to avoid incorrectly specified
isSigned flags. A recurring problem we have is that people write
something like `APInt(BW, -1)` and this works perfectly fine -- until
the code path is hit with `BW > 64`. Most of our i128 specific
miscompilations are caused by variants of this issue.

The cost of the change is that we have to specify the correct isSigned
flag (and make sure there are no excess bits) for uses where BW is
always <= 64 as well.

show more ...


Revision tags: llvmorg-19.1.0-rc3
# cbd30680 14-Aug-2024 Craig Topper <craig.topper@sifive.com>

[APInt] Correct backwards static_assert condition. (#103641)

In order to guarantee that extracting 64 bits doesn't require more than
2 words, the word size would need to be 64 bits or more. If the

[APInt] Correct backwards static_assert condition. (#103641)

In order to guarantee that extracting 64 bits doesn't require more than
2 words, the word size would need to be 64 bits or more. If the word
size was smaller than 64, like 32, you may need to read 3 words to get
64 bits.

show more ...


# 7f1f3afd 14-Aug-2024 Craig Topper <craig.topper@sifive.com>

[APInt] Use APINT_BITS_PER_WORD instead of recomputing it. NFC


Revision tags: llvmorg-19.1.0-rc2, llvmorg-19.1.0-rc1, llvmorg-20-init, llvmorg-18.1.8, llvmorg-18.1.7, llvmorg-18.1.6, llvmorg-18.1.5, llvmorg-18.1.4
# 900be901 12-Apr-2024 Victor Toni <ViToni@users.noreply.github.com>

Fix typos (#88565)


# d8f1e5d2 10-Apr-2024 Craig Topper <craig.topper@sifive.com>

[APInt] Remove accumulator initialization from tcMultiply and tcFullMultiply. NFCI (#88202)

The tcMultiplyPart routine has a flag that says whether to add to the
accumulator or overwrite it. By usi

[APInt] Remove accumulator initialization from tcMultiply and tcFullMultiply. NFCI (#88202)

The tcMultiplyPart routine has a flag that says whether to add to the
accumulator or overwrite it. By using the overwrite mode on the first
iteration we don't need to initialize the accumulator to zero.

Note, the initialization in tcFullMultiply was only initializing the
first rhsParts of dst. tcMultiplyPart always overwrites the rhsParts+1
part that just contains the last carry. The first write to each part of
dst past rhsParts is a carry write so that's how the upper part of dst
is initialized.

show more ...


# 04f33a3a 09-Apr-2024 Craig Topper <craig.topper@sifive.com>

[APInt] Use a std::move() to avoid a copy in the loop in multiplicativeInverse. (#87655)

This allows the subtract to reuse the storage of T. T will be assigned
over by the condition on the next ite

[APInt] Use a std::move() to avoid a copy in the loop in multiplicativeInverse. (#87655)

This allows the subtract to reuse the storage of T. T will be assigned
over by the condition on the next iteration. I think assigning over a
moved from value should be ok.

show more ...


# 0b293e8c 04-Apr-2024 Jay Foad <jay.foad@amd.com>

[APInt] Remove multiplicativeInverse with explicit modulus (#87644)

All callers have been changed to use the new simpler overload with an
implicit modulus of 2^BitWidth. The old form was never used

[APInt] Remove multiplicativeInverse with explicit modulus (#87644)

All callers have been changed to use the new simpler overload with an
implicit modulus of 2^BitWidth. The old form was never used or tested
with non-power-of-two modulus anyway.

show more ...


# 1b761205 04-Apr-2024 Jay Foad <jay.foad@amd.com>

[APInt] Add a simpler overload of multiplicativeInverse (#87610)

The current APInt::multiplicativeInverse takes a modulus which can be
any value, but all in-tree callers use a power of two. Moreove

[APInt] Add a simpler overload of multiplicativeInverse (#87610)

The current APInt::multiplicativeInverse takes a modulus which can be
any value, but all in-tree callers use a power of two. Moreover, most
callers want to use two to the power of the width of an existing APInt,
which is awkward because 2^N is not representable as an N-bit APInt.

Add a new overload of multiplicativeInverse which implicitly uses
2^BitWidth as the modulus.

show more ...


Revision tags: llvmorg-18.1.3
# 4aba595f 02-Apr-2024 Atousa Duprat <atousa.p@gmail.com>

[ADT] Add signed and unsigned mulh to APInt (#84719)

Fixes #84207


Revision tags: llvmorg-18.1.2
# 6d30223f 15-Mar-2024 long.chen <lipracer@gmail.com>

[ADT][APInt] add sfloordiv_ov APInt's member function (#84720)

for mlir fold to avoid too many overflow state check


# 4e232cab 14-Mar-2024 Jay Foad <jay.foad@amd.com>

[APInt] Implement average functions without sign/zero-extension. NFC. (#85212)

Removing the extension to FullWidth should make them much more efficient
in the 64-bit case, because 65-bit APInts use

[APInt] Implement average functions without sign/zero-extension. NFC. (#85212)

Removing the extension to FullWidth should make them much more efficient
in the 64-bit case, because 65-bit APInts use a separate allocation for
their bits.

show more ...


# aff05708 14-Mar-2024 Atousa Duprat <atousa.p@gmail.com>

[ADT] Add implementations for avgFloor and avgCeil to APInt (#84431)

Supports both signed and unsigned expansions.

SelectionDAG now calls the APInt implementation of these functions.

Fixes #84

[ADT] Add implementations for avgFloor and avgCeil to APInt (#84431)

Supports both signed and unsigned expansions.

SelectionDAG now calls the APInt implementation of these functions.

Fixes #84211.

show more ...


Revision tags: llvmorg-18.1.1
# c00c901f 05-Mar-2024 Atousa Duprat <atousa.p@gmail.com>

[clang] Use separator for large numeric values in overflow diagnostic (#80939)

Add functionality to APInt::toString() that allows it to insert
separators between groups of digits, using the C++ lit

[clang] Use separator for large numeric values in overflow diagnostic (#80939)

Add functionality to APInt::toString() that allows it to insert
separators between groups of digits, using the C++ literal
separator ' between groups.

Fixes issue #58228

Reviewers: @AaronBallman, @cjdb, @tbaederr

show more ...


Revision tags: llvmorg-18.1.0, llvmorg-18.1.0-rc4, llvmorg-18.1.0-rc3, llvmorg-18.1.0-rc2, llvmorg-18.1.0-rc1, llvmorg-19-init, llvmorg-17.0.6, llvmorg-17.0.5, llvmorg-17.0.4, llvmorg-17.0.3, llvmorg-17.0.2, llvmorg-17.0.1, llvmorg-17.0.0, llvmorg-17.0.0-rc4, llvmorg-17.0.0-rc3, llvmorg-17.0.0-rc2, llvmorg-17.0.0-rc1, llvmorg-18-init
# b745c123 26-Jun-2023 Guillaume Chatelet <gchatelet@google.com>

[Align] Add isAligned taking an APInt

This showed up in https://reviews.llvm.org/D153308

Reviewed By: courbet, nikic

Differential Revision: https://reviews.llvm.org/D153356


Revision tags: llvmorg-16.0.6, llvmorg-16.0.5
# 42e98c6a 31-May-2023 Nikita Popov <npopov@redhat.com>

[APInt] Support zero-width extract in extractBitsAsZExtValue()

D111241 added support for extractBits() with zero width. Extend this
to extractBitsAsZExtValue() as well for consistency (in which case

[APInt] Support zero-width extract in extractBitsAsZExtValue()

D111241 added support for extractBits() with zero width. Extend this
to extractBitsAsZExtValue() as well for consistency (in which case
it will always return zero).

Differential Revision: https://reviews.llvm.org/D151788

show more ...


# bf358e27 25-May-2023 Jay Foad <jay.foad@amd.com>

[APInt] Add unsigned overloads of shift functions

Add overloads of sshl_ov, ushl_ov, sshl_sat and ushl_sat that take the
shift amount as unsigned instead of APInt. This matches what we do for
the no

[APInt] Add unsigned overloads of shift functions

Add overloads of sshl_ov, ushl_ov, sshl_sat and ushl_sat that take the
shift amount as unsigned instead of APInt. This matches what we do for
the normal shift operators and can help to avoid creating temporary
APInts in some cases.

Differential Revision: https://reviews.llvm.org/D151420

show more ...


# a1708340 18-May-2023 Thomas Preud'homme <thomas.preudhomme@arm.com>

Add control of hex casing in APInt::toString

This will be used in implementing arbitrary precision support to
FileCheck's numeric variables and expressions.

Reviewed By: foad, RKSimon

Differential

Add control of hex casing in APInt::toString

This will be used in implementing arbitrary precision support to
FileCheck's numeric variables and expressions.

Reviewed By: foad, RKSimon

Differential Revision: https://reviews.llvm.org/D150879

show more ...


Revision tags: llvmorg-16.0.4, llvmorg-16.0.3, llvmorg-16.0.2, llvmorg-16.0.1, llvmorg-16.0.0, llvmorg-16.0.0-rc4, llvmorg-16.0.0-rc3
# f8f3db27 20-Feb-2023 Kazu Hirata <kazu@google.com>

Use APInt::count{l,r}_{zero,one} (NFC)


# 36606cf0 10-Feb-2023 Pavel Kopyl <pavelkopyl@gmail.com>

[NFC] Replace -1U{LL} expressions with appropriate *_MAX macros in Support library.

This makes a code a bit more clear and also gets rid of C4146 warning
on MSVC compiler:
'unary minus operator app

[NFC] Replace -1U{LL} expressions with appropriate *_MAX macros in Support library.

This makes a code a bit more clear and also gets rid of C4146 warning
on MSVC compiler:
'unary minus operator applied to unsigned type, result still unsigned'.

In case uint64_t variable is initialized or compared against -1U expression,
which corresponds to 32-bit constant, UINT_MAX macro is used to preserve
NFC semantics; -1ULL is replaced with UINT64_MAX.

Reviewed By: dblaikie, craig.topper

Differential Revision: https://reviews.llvm.org/D143942

show more ...


Revision tags: llvmorg-16.0.0-rc2
# f6b8f05b 28-Jan-2023 Kazu Hirata <kazu@google.com>

Use llvm::byteswap instead of ByteSwap_{16,32,64} (NFC)


12345678910>>...18