diff options
author | Sanjay Patel <spatel@rotateright.com> | 2016-08-21 15:07:45 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2016-08-21 15:07:45 +0000 |
commit | 792636603f5b63bcf3402a4100ed23c494bc9902 (patch) | |
tree | 287f29e18805ca8548178058f67c701eb1bd1d92 /llvm/lib/Transforms | |
parent | 5f99f8656e542c0e0fc52b6f8741b3c01afdb76e (diff) | |
download | bcm5719-llvm-792636603f5b63bcf3402a4100ed23c494bc9902.tar.gz bcm5719-llvm-792636603f5b63bcf3402a4100ed23c494bc9902.zip |
[InstCombine] use APInt instead of ConstantInt in isSignBitCheck(); NFCI
The callers still have ConstantInt guards, so there is no functional change
intended from this change. But relaxing the callers will allow more folds
for vector types.
llvm-svn: 279396
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index 33d97e10aa8..220d783b058 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -126,26 +126,26 @@ static bool isBranchOnSignBitCheck(ICmpInst &I, bool isSignBit) { /// Given an exploded icmp instruction, return true if the comparison only /// checks the sign bit. If it only checks the sign bit, set TrueIfSigned if the /// result of the comparison is true when the input value is signed. -static bool isSignBitCheck(ICmpInst::Predicate Pred, ConstantInt *RHS, +static bool isSignBitCheck(ICmpInst::Predicate Pred, const APInt &RHS, bool &TrueIfSigned) { switch (Pred) { case ICmpInst::ICMP_SLT: // True if LHS s< 0 TrueIfSigned = true; - return RHS->isZero(); + return RHS == 0; case ICmpInst::ICMP_SLE: // True if LHS s<= RHS and RHS == -1 TrueIfSigned = true; - return RHS->isAllOnesValue(); + return RHS.isAllOnesValue(); case ICmpInst::ICMP_SGT: // True if LHS s> -1 TrueIfSigned = false; - return RHS->isAllOnesValue(); + return RHS.isAllOnesValue(); case ICmpInst::ICMP_UGT: // True if LHS u> RHS and RHS == high-bit-mask - 1 TrueIfSigned = true; - return RHS->isMaxValue(true); + return RHS.isMaxSignedValue(); case ICmpInst::ICMP_UGE: // True if LHS u>= RHS and RHS == high-bit-mask (2^7, 2^15, 2^31, etc) TrueIfSigned = true; - return RHS->getValue().isSignBit(); + return RHS.isSignBit(); default: return false; } @@ -2037,7 +2037,7 @@ Instruction *InstCombiner::foldICmpShlConstant(ICmpInst &Cmp, Instruction *Shl, // Otherwise, if this is a comparison of the sign bit, simplify to and/test. bool TrueIfSigned = false; - if (Shl->hasOneUse() && isSignBitCheck(Pred, RHS, TrueIfSigned)) { + if (Shl->hasOneUse() && isSignBitCheck(Pred, *C, TrueIfSigned)) { // (X << 31) <s 0 --> (X&1) != 0 Constant *Mask = ConstantInt::get( X->getType(), @@ -3416,7 +3416,7 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) { // If this comparison is a normal comparison, it demands all // bits, if it is a sign bit comparison, it only demands the sign bit. bool UnusedBit; - isSignBit = isSignBitCheck(I.getPredicate(), CI, UnusedBit); + isSignBit = isSignBitCheck(I.getPredicate(), CI->getValue(), UnusedBit); // Canonicalize icmp instructions based on dominating conditions. BasicBlock *Parent = I.getParent(); |