[llvm] r281644 - [InstCombine] simplify code; NFCI
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 15 12:04:55 PDT 2016
Author: spatel
Date: Thu Sep 15 14:04:55 2016
New Revision: 281644
URL: http://llvm.org/viewvc/llvm-project?rev=281644&view=rev
Log:
[InstCombine] simplify code; NFCI
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=281644&r1=281643&r2=281644&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Thu Sep 15 14:04:55 2016
@@ -1181,12 +1181,6 @@ Instruction *InstCombiner::foldICmpCstSh
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::foldICmpCstSh
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::foldICmpCstSh
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::foldICmpCstSh
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:
More information about the llvm-commits
mailing list