diff options
author | Nikita Popov <npopov@redhat.com> | 2024-10-17 08:48:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-17 08:48:08 +0200 |
commit | 255a99c29f9fa1a89b03a85a3a73d6f44d03c6c1 (patch) | |
tree | 1b1811317caef3bc3b27386d4c5a76de8b4034b5 /llvm/lib/Analysis/ConstantFolding.cpp | |
parent | 3ae6b57671744b4fe4dd76769cce0745a0f5bc31 (diff) | |
download | llvm-255a99c29f9fa1a89b03a85a3a73d6f44d03c6c1.zip llvm-255a99c29f9fa1a89b03a85a3a73d6f44d03c6c1.tar.gz llvm-255a99c29f9fa1a89b03a85a3a73d6f44d03c6c1.tar.bz2 |
[APInt] Fix APInt constructions where value does not fit bitwidth (NFCI) (#80309)
This fixes all the places that hit the new assertion added in
https://github.com/llvm/llvm-project/pull/106524 in tests. That is,
cases where the value passed to the APInt constructor is not an N-bit
signed/unsigned integer, where N is the bit width and signedness is
determined by the isSigned flag.
The fixes either set the correct value for isSigned, set the
implicitTrunc flag, or perform more calculations inside APInt.
Note that the assertion is currently still disabled by default, so this
patch is mostly NFC.
Diffstat (limited to 'llvm/lib/Analysis/ConstantFolding.cpp')
-rw-r--r-- | llvm/lib/Analysis/ConstantFolding.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp index 3af4ae3..da0fd1f 100644 --- a/llvm/lib/Analysis/ConstantFolding.cpp +++ b/llvm/lib/Analysis/ConstantFolding.cpp @@ -888,7 +888,8 @@ Constant *SymbolicallyEvaluateGEP(const GEPOperator *GEP, APInt Offset = APInt( BitWidth, DL.getIndexedOffsetInType( - SrcElemTy, ArrayRef((Value *const *)Ops.data() + 1, Ops.size() - 1))); + SrcElemTy, ArrayRef((Value *const *)Ops.data() + 1, Ops.size() - 1)), + /*isSigned=*/true, /*implicitTrunc=*/true); std::optional<ConstantRange> InRange = GEP->getInRange(); if (InRange) |