forked from OSchip/llvm-project
[ConstantRange] Rewrite shl to avoid repeated calls to getUnsignedMax and avoid creating the min APInt until we're sure we need it. Use inplace shift operations.
llvm-svn: 302510
This commit is contained in:
parent
79b7666f02
commit
ef02803bed
|
@ -892,16 +892,20 @@ ConstantRange::shl(const ConstantRange &Other) const {
|
||||||
if (isEmptySet() || Other.isEmptySet())
|
if (isEmptySet() || Other.isEmptySet())
|
||||||
return ConstantRange(getBitWidth(), /*isFullSet=*/false);
|
return ConstantRange(getBitWidth(), /*isFullSet=*/false);
|
||||||
|
|
||||||
APInt min = getUnsignedMin().shl(Other.getUnsignedMin());
|
APInt max = getUnsignedMax();
|
||||||
APInt max = getUnsignedMax().shl(Other.getUnsignedMax());
|
APInt Other_umax = Other.getUnsignedMax();
|
||||||
|
|
||||||
// there's no overflow!
|
// there's overflow!
|
||||||
APInt Zeros(getBitWidth(), getUnsignedMax().countLeadingZeros());
|
if (Other_umax.uge(max.countLeadingZeros()))
|
||||||
if (Zeros.ugt(Other.getUnsignedMax()))
|
return ConstantRange(getBitWidth(), /*isFullSet=*/true);
|
||||||
return ConstantRange(std::move(min), std::move(max) + 1);
|
|
||||||
|
|
||||||
// FIXME: implement the other tricky cases
|
// FIXME: implement the other tricky cases
|
||||||
return ConstantRange(getBitWidth(), /*isFullSet=*/true);
|
|
||||||
|
APInt min = getUnsignedMin();
|
||||||
|
min <<= Other.getUnsignedMin();
|
||||||
|
max <<= Other_umax;
|
||||||
|
|
||||||
|
return ConstantRange(std::move(min), std::move(max) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConstantRange
|
ConstantRange
|
||||||
|
|
Loading…
Reference in New Issue