aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ValueTracking.cpp
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2024-09-05 16:02:50 +0200
committerNikita Popov <npopov@redhat.com>2024-09-05 16:11:00 +0200
commit9707b98e572adf34ef3e71bcf159dae08e654fd8 (patch)
tree56af2b71762e23c1ae52d2bb8a8a4f7a39de37c1 /llvm/lib/Analysis/ValueTracking.cpp
parent233ed51cf53d590d3f52d5becff95317dbf73657 (diff)
downloadllvm-9707b98e572adf34ef3e71bcf159dae08e654fd8.zip
llvm-9707b98e572adf34ef3e71bcf159dae08e654fd8.tar.gz
llvm-9707b98e572adf34ef3e71bcf159dae08e654fd8.tar.bz2
[ConstantRange] Perform increment on APInt (NFC)
This handles the edge case where BitWidth is 1 and doing the increment gets a value that's not valid in that width, while we just want wrap-around. Split out of https://github.com/llvm/llvm-project/pull/80309.
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r--llvm/lib/Analysis/ValueTracking.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 8f35fd5..3a0ec99 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -9596,7 +9596,7 @@ static ConstantRange getRangeForIntrinsic(const IntrinsicInst &II) {
case Intrinsic::cttz:
// Maximum of set/clear bits is the bit width.
return ConstantRange::getNonEmpty(APInt::getZero(Width),
- APInt(Width, Width + 1));
+ APInt(Width, Width) + 1);
case Intrinsic::uadd_sat:
// uadd.sat(x, C) produces [C, UINT_MAX].
if (match(II.getOperand(0), m_APInt(C)) ||