diff options
author | Sanjay Patel <spatel@rotateright.com> | 2016-09-28 13:53:13 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2016-09-28 13:53:13 +0000 |
commit | 1b312ad42d1bb898c8f386e0d22f823b5c12f526 (patch) | |
tree | 06c331cd97a5fb01aea8b4b2b725b1e321660258 /llvm/lib | |
parent | 47ca99b3726dc6d1f5b0de986848f608741bc5a4 (diff) | |
download | bcm5719-llvm-1b312ad42d1bb898c8f386e0d22f823b5c12f526.tar.gz bcm5719-llvm-1b312ad42d1bb898c8f386e0d22f823b5c12f526.zip |
[InstSimplify] allow and-of-icmps folds with vector splat constants
llvm-svn: 282590
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Analysis/InstructionSimplify.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index d42cad92e76..5f38ffe32f7 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -1518,23 +1518,22 @@ static Value *SimplifyAndOfICmps(ICmpInst *Op0, ICmpInst *Op1) { return getFalse(ITy); } - // FIXME: Use m_APInt to allow vector splat matches. - ConstantInt *CI1, *CI2; - if (!match(Op0, m_ICmp(Pred0, m_Add(m_Value(V), m_ConstantInt(CI1)), - m_ConstantInt(CI2)))) + // (icmp (add V, C0), C1) & (icmp V, C0) + if (!match(Op0, m_ICmp(Pred0, m_Add(m_Value(V), m_APInt(C0)), m_APInt(C1)))) return nullptr; - if (!match(Op1, m_ICmp(Pred1, m_Specific(V), m_Specific(CI1)))) + if (!match(Op1, m_ICmp(Pred1, m_Specific(V), m_Value()))) return nullptr; auto *AddInst = cast<BinaryOperator>(Op0->getOperand(0)); + if (AddInst->getOperand(1) != Op1->getOperand(1)) + return nullptr; + bool isNSW = AddInst->hasNoSignedWrap(); bool isNUW = AddInst->hasNoUnsignedWrap(); - const APInt &CI1V = CI1->getValue(); - const APInt &CI2V = CI2->getValue(); - const APInt Delta = CI2V - CI1V; - if (CI1V.isStrictlyPositive()) { + const APInt Delta = *C1 - *C0; + if (C0->isStrictlyPositive()) { if (Delta == 2) { if (Pred0 == ICmpInst::ICMP_ULT && Pred1 == ICmpInst::ICMP_SGT) return getFalse(ITy); @@ -1548,7 +1547,7 @@ static Value *SimplifyAndOfICmps(ICmpInst *Op0, ICmpInst *Op1) { return getFalse(ITy); } } - if (CI1V.getBoolValue() && isNUW) { + if (C0->getBoolValue() && isNUW) { if (Delta == 2) if (Pred0 == ICmpInst::ICMP_ULT && Pred1 == ICmpInst::ICMP_UGT) return getFalse(ITy); |