diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2016-08-16 21:26:10 +0000 |
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2016-08-16 21:26:10 +0000 |
| commit | b9aa67bfcfb097d7bd3f21fb94be86bde331c676 (patch) | |
| tree | 8f8d23d2a5adbf96e3fd4dc139578cfcd357c3ce /llvm | |
| parent | 110522bc0fe8e6d4a8f9baaea4f58f1cb827d92d (diff) | |
| download | bcm5719-llvm-b9aa67bfcfb097d7bd3f21fb94be86bde331c676.tar.gz bcm5719-llvm-b9aa67bfcfb097d7bd3f21fb94be86bde331c676.zip | |
[InstCombine] fix variable names to match formula comments; NFC
llvm-svn: 278855
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index 4cbb22aceff..0e5596190bf 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -2167,35 +2167,35 @@ Instruction *InstCombiner::foldICmpDivConstant(ICmpInst &ICI, Instruction *LHSI, return nullptr; } -Instruction *InstCombiner::foldICmpSubConstant(ICmpInst &ICI, Instruction *LHSI, - const APInt *RHSV) { +/// Fold icmp (sub X, Y), C. +Instruction *InstCombiner::foldICmpSubConstant(ICmpInst &Cmp, Instruction *Sub, + const APInt *C) { // FIXME: This check restricts all folds under here to scalar types. - ConstantInt *RHS = dyn_cast<ConstantInt>(ICI.getOperand(1)); + ConstantInt *RHS = dyn_cast<ConstantInt>(Cmp.getOperand(1)); if (!RHS) return nullptr; - ConstantInt *LHSC = dyn_cast<ConstantInt>(LHSI->getOperand(0)); - if (!LHSC) + ConstantInt *SubC = dyn_cast<ConstantInt>(Sub->getOperand(0)); + if (!SubC) return nullptr; - const APInt &LHSV = LHSC->getValue(); + const APInt &C2 = SubC->getValue(); - // C1-X <u C2 -> (X|(C2-1)) == C1 - // iff C1 & (C2-1) == C2-1 + // C-X <u C2 -> (X|(C2-1)) == C + // iff C & (C2-1) == C2-1 // C2 is a power of 2 - if (ICI.getPredicate() == ICmpInst::ICMP_ULT && LHSI->hasOneUse() && - RHSV->isPowerOf2() && (LHSV & (*RHSV - 1)) == (*RHSV - 1)) + if (Cmp.getPredicate() == ICmpInst::ICMP_ULT && Sub->hasOneUse() && + C->isPowerOf2() && (C2 & (*C - 1)) == (*C - 1)) return new ICmpInst(ICmpInst::ICMP_EQ, - Builder->CreateOr(LHSI->getOperand(1), *RHSV - 1), - LHSC); + Builder->CreateOr(Sub->getOperand(1), *C - 1), SubC); - // C1-X >u C2 -> (X|C2) != C1 - // iff C1 & C2 == C2 + // C-X >u C2 -> (X|C2) != C + // iff C & C2 == C2 // C2+1 is a power of 2 - if (ICI.getPredicate() == ICmpInst::ICMP_UGT && LHSI->hasOneUse() && - (*RHSV + 1).isPowerOf2() && (LHSV & *RHSV) == *RHSV) + if (Cmp.getPredicate() == ICmpInst::ICMP_UGT && Sub->hasOneUse() && + (*C + 1).isPowerOf2() && (C2 & *C) == *C) return new ICmpInst(ICmpInst::ICMP_NE, - Builder->CreateOr(LHSI->getOperand(1), *RHSV), LHSC); + Builder->CreateOr(Sub->getOperand(1), *C), SubC); return nullptr; } |

