diff options
author | Sanjay Patel <spatel@rotateright.com> | 2016-09-15 19:04:55 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2016-09-15 19:04:55 +0000 |
commit | 524fcdf04171ae716b51aafa19f261954b42e9d1 (patch) | |
tree | 993a0a9ce9bfc49acbb82d2f0242913fb676ceea /llvm | |
parent | 7f382999197ae4629e87ab9a2872664723a16451 (diff) | |
download | bcm5719-llvm-524fcdf04171ae716b51aafa19f261954b42e9d1.tar.gz bcm5719-llvm-524fcdf04171ae716b51aafa19f261954b42e9d1.zip |
[InstCombine] simplify code; NFCI
llvm-svn: 281644
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index dd59ddd102b..56fa93332f5 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -1181,12 +1181,6 @@ Instruction *InstCombiner::foldICmpCstShrConst(ICmpInst &I, Value *Op, Value *A, ConstantInt *CI2) { assert(I.isEquality() && "Cannot fold icmp gt/lt"); - auto getConstant = [&I, this](bool IsTrue) { - if (I.getPredicate() == I.ICMP_NE) - IsTrue = !IsTrue; - return replaceInstUsesWith(I, ConstantInt::get(I.getType(), IsTrue)); - }; - auto getICmp = [&I](CmpInst::Predicate Pred, Value *LHS, Value *RHS) { if (I.getPredicate() == I.ICMP_NE) Pred = CmpInst::getInversePredicate(Pred); @@ -1234,8 +1228,11 @@ Instruction *InstCombiner::foldICmpCstShrConst(ICmpInst &I, Value *Op, Value *A, return getICmp(I.ICMP_EQ, A, ConstantInt::get(A->getType(), Shift)); } } + // Shifting const2 will never be equal to const1. - return getConstant(false); + // FIXME: This should always be handled by InstSimplify? + auto *TorF = ConstantInt::get(I.getType(), I.getPredicate() == I.ICMP_NE); + return replaceInstUsesWith(I, TorF); } /// Handle "(icmp eq/ne (shl const2, A), const1)" -> @@ -1245,12 +1242,6 @@ Instruction *InstCombiner::foldICmpCstShlConst(ICmpInst &I, Value *Op, Value *A, ConstantInt *CI2) { assert(I.isEquality() && "Cannot fold icmp gt/lt"); - auto getConstant = [&I, this](bool IsTrue) { - if (I.getPredicate() == I.ICMP_NE) - IsTrue = !IsTrue; - return replaceInstUsesWith(I, ConstantInt::get(I.getType(), IsTrue)); - }; - auto getICmp = [&I](CmpInst::Predicate Pred, Value *LHS, Value *RHS) { if (I.getPredicate() == I.ICMP_NE) Pred = CmpInst::getInversePredicate(Pred); @@ -1280,7 +1271,9 @@ Instruction *InstCombiner::foldICmpCstShlConst(ICmpInst &I, Value *Op, Value *A, return getICmp(I.ICMP_EQ, A, ConstantInt::get(A->getType(), Shift)); // Shifting const2 will never be equal to const1. - return getConstant(false); + // FIXME: This should always be handled by InstSimplify? + auto *TorF = ConstantInt::get(I.getType(), I.getPredicate() == I.ICMP_NE); + return replaceInstUsesWith(I, TorF); } /// The caller has matched a pattern of the form: |