Skip to content

Commit 9d16764

Browse files
committed
fixup! [ConstantRange] Handle Intrinsic::cttz
1 parent ddceeff commit 9d16764

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

llvm/lib/IR/ConstantRange.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,46 +1772,45 @@ ConstantRange ConstantRange::cttz(bool ZeroIsPoison) const {
17721772
if (isEmptySet())
17731773
return getEmpty();
17741774

1775-
APInt Zero = APInt::getZero(getBitWidth());
1776-
1775+
unsigned BitWidth = getBitWidth();
1776+
APInt Zero = APInt::getZero(BitWidth);
17771777
if (ZeroIsPoison && contains(Zero)) {
17781778
// ZeroIsPoison is set, and zero is contained. We discern three cases, in
17791779
// which a zero can appear:
17801780
// 1) Lower is zero, handling cases of kind [0, 1), [0, 2), etc.
17811781
// 2) Upper is zero, wrapped set, handling cases of kind [3, 0], etc.
17821782
// 3) Zero contained in a wrapped set, e.g., [3, 2), [3, 1), etc.
17831783

1784-
if (getLower().isZero()) {
1785-
if (getUpper() == 1) {
1784+
if (Lower.isZero()) {
1785+
if (Upper == 1) {
17861786
// We have in input interval of kind [0, 1). In this case we cannot
17871787
// really help but return empty-set.
17881788
return getEmpty();
17891789
}
17901790

17911791
// Compute the resulting range by excluding zero from Lower.
1792-
return getUnsignedCountTrailingZerosRange(APInt(getBitWidth(), 1),
1793-
getUpper());
1794-
} else if (getUpper() == 1) {
1792+
return getUnsignedCountTrailingZerosRange(APInt(BitWidth, 1), Upper);
1793+
} else if (Upper == 1) {
17951794
// Compute the resulting range by excluding zero from Upper.
1796-
return getUnsignedCountTrailingZerosRange(getLower(), Zero);
1795+
return getUnsignedCountTrailingZerosRange(Lower, Zero);
17971796
} else {
1798-
ConstantRange CR1 = getUnsignedCountTrailingZerosRange(getLower(), Zero);
1799-
ConstantRange CR2 = getUnsignedCountTrailingZerosRange(
1800-
APInt(getBitWidth(), 1), getUpper());
1797+
ConstantRange CR1 = getUnsignedCountTrailingZerosRange(Lower, Zero);
1798+
ConstantRange CR2 =
1799+
getUnsignedCountTrailingZerosRange(APInt(BitWidth, 1), Upper);
18011800
return CR1.unionWith(CR2);
18021801
}
18031802
}
18041803

18051804
if (isFullSet())
1806-
return getNonEmpty(Zero, APInt(getBitWidth(), getBitWidth() + 1));
1805+
return getNonEmpty(Zero, APInt(BitWidth, BitWidth + 1));
18071806
if (!isWrappedSet())
1808-
return getUnsignedCountTrailingZerosRange(getLower(), getUpper());
1807+
return getUnsignedCountTrailingZerosRange(Lower, Upper);
18091808
// The range is wrapped. We decompose it into two ranges, [0, Upper) and
18101809
// [Lower, 0).
18111810
// Handle [Lower, 0)
1812-
ConstantRange CR1 = getUnsignedCountTrailingZerosRange(getLower(), Zero);
1811+
ConstantRange CR1 = getUnsignedCountTrailingZerosRange(Lower, Zero);
18131812
// Handle [0, Upper)
1814-
ConstantRange CR2 = getUnsignedCountTrailingZerosRange(Zero, getUpper());
1813+
ConstantRange CR2 = getUnsignedCountTrailingZerosRange(Zero, Upper);
18151814
return CR1.unionWith(CR2);
18161815
}
18171816

0 commit comments

Comments
 (0)