diff options
author | Craig Topper <craig.topper@gmail.com> | 2017-04-29 07:24:13 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2017-04-29 07:24:13 +0000 |
commit | 8fb5a14cadd55ba865b802fbe77fdd60253b9bf3 (patch) | |
tree | b7296be231cf8e15e8f683e46f54fb23c62ec7c6 /llvm/lib | |
parent | b792025bed9b2d877481d5e1d1afc3f0dc6d7e3c (diff) | |
download | bcm5719-llvm-8fb5a14cadd55ba865b802fbe77fdd60253b9bf3.tar.gz bcm5719-llvm-8fb5a14cadd55ba865b802fbe77fdd60253b9bf3.zip |
[ConstantRange] Use ternary operator instead of 'if' to avoid copying an APInt and then possibly copying over it.
llvm-svn: 301741
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/IR/ConstantRange.cpp | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/llvm/lib/IR/ConstantRange.cpp b/llvm/lib/IR/ConstantRange.cpp index 9c6ecbe73dd..fd678c28256 100644 --- a/llvm/lib/IR/ConstantRange.cpp +++ b/llvm/lib/IR/ConstantRange.cpp @@ -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)); } |