aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ValueTracking.cpp
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2023-05-17 12:20:21 +0200
committerNikita Popov <npopov@redhat.com>2023-05-17 12:31:13 +0200
commit9b7616856cbdd476aaf4553ccc74ab8c38c5f6ad (patch)
treec9c34bef6011fe87b3856dc04993cdfe3978075f /llvm/lib/Analysis/ValueTracking.cpp
parent7d9f03f4d8e1d59da267a863e0018f2e172ca0f9 (diff)
downloadllvm-9b7616856cbdd476aaf4553ccc74ab8c38c5f6ad.zip
llvm-9b7616856cbdd476aaf4553ccc74ab8c38c5f6ad.tar.gz
llvm-9b7616856cbdd476aaf4553ccc74ab8c38c5f6ad.tar.bz2
[ValueTracking] Fix i1 abs range (PR62760)
For i1 operations, we may end up returning an empty range instead of a full one. Make sure to use the getNonEmpty constructor. Fixes https://github.com/llvm/llvm-project/issues/62760.
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r--llvm/lib/Analysis/ValueTracking.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 0368c09..6f602da 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -8701,7 +8701,8 @@ static ConstantRange getRangeForIntrinsic(const IntrinsicInst &II) {
case Intrinsic::ctlz:
case Intrinsic::cttz:
// Maximum of set/clear bits is the bit width.
- return ConstantRange(APInt::getZero(Width), APInt(Width, Width + 1));
+ return ConstantRange::getNonEmpty(APInt::getZero(Width),
+ APInt(Width, Width + 1));
case Intrinsic::uadd_sat:
// uadd.sat(x, C) produces [C, UINT_MAX].
if (match(II.getOperand(0), m_APInt(C)) ||
@@ -8782,11 +8783,11 @@ static ConstantRange getRangeForIntrinsic(const IntrinsicInst &II) {
// If abs of SIGNED_MIN is poison, then the result is [0..SIGNED_MAX],
// otherwise it is [0..SIGNED_MIN], as -SIGNED_MIN == SIGNED_MIN.
if (match(II.getOperand(1), m_One()))
- return ConstantRange(APInt::getZero(Width),
- APInt::getSignedMaxValue(Width) + 1);
+ return ConstantRange::getNonEmpty(APInt::getZero(Width),
+ APInt::getSignedMaxValue(Width) + 1);
- return ConstantRange(APInt::getZero(Width),
- APInt::getSignedMinValue(Width) + 1);
+ return ConstantRange::getNonEmpty(APInt::getZero(Width),
+ APInt::getSignedMinValue(Width) + 1);
case Intrinsic::vscale:
if (!II.getParent() || !II.getFunction())
break;