[ConstantRange] Use ternary operator instead of 'if' to avoid copying an APInt and then possibly copying over it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301741 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Craig Topper 2017-04-29 07:24:13 +00:00
parent 9a418e88ed
commit 5529b11227

View File

@ -431,11 +431,8 @@ ConstantRange ConstantRange::unionWith(const ConstantRange &CR) const {
return ConstantRange(CR.Lower, Upper);
}
APInt L = Lower, U = Upper;
if (CR.Lower.ult(L))
L = CR.Lower;
if ((CR.Upper - 1).ugt(U - 1))
U = CR.Upper;
APInt L = CR.Lower.ult(Lower) ? CR.Lower : Lower;
APInt U = (CR.Upper - 1).ugt(Upper - 1) ? CR.Upper : Upper;
if (L == 0 && U == 0)
return ConstantRange(getBitWidth());
@ -481,11 +478,8 @@ ConstantRange ConstantRange::unionWith(const ConstantRange &CR) const {
if (CR.Lower.ule(Upper) || Lower.ule(CR.Upper))
return ConstantRange(getBitWidth());
APInt L = Lower, U = Upper;
if (CR.Upper.ugt(U))
U = CR.Upper;
if (CR.Lower.ult(L))
L = CR.Lower;
APInt L = CR.Lower.ult(Lower) ? CR.Lower : Lower;
APInt U = CR.Upper.ugt(Upper) ? CR.Upper : Upper;
return ConstantRange(std::move(L), std::move(U));
}