diff options
author | Sanjay Patel <spatel@rotateright.com> | 2016-07-23 00:28:39 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2016-07-23 00:28:39 +0000 |
commit | 6ebd5857c8f63d5167aa06fa9cecddd54a5832be (patch) | |
tree | cc6ac804330a3ba59251e31479bfb80719111500 /llvm/lib/Transforms | |
parent | 8d8594acb935a11146b255c52a335fa718eec44d (diff) | |
download | bcm5719-llvm-6ebd5857c8f63d5167aa06fa9cecddd54a5832be.tar.gz bcm5719-llvm-6ebd5857c8f63d5167aa06fa9cecddd54a5832be.zip |
[InstCombine] move udiv+cmp fold over with other BinOp+cmp folds; NFCI
llvm-svn: 276502
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index c568629e4a5..f5514a8992e 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -2341,6 +2341,14 @@ Instruction *InstCombiner::foldICmpEqualityWithConstant(ICmpInst &ICI, } } break; + case Instruction::UDiv: + if (RHSV == 0) { + // (icmp eq/ne (udiv A, B), 0) -> (icmp ugt/ule i32 B, A) + ICmpInst::Predicate Pred = + isICMP_NE ? ICmpInst::ICMP_ULE : ICmpInst::ICMP_UGT; + return new ICmpInst(Pred, BO->getOperand(1), BO->getOperand(0)); + } + break; default: break; } @@ -3634,7 +3642,6 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) { // See if we are doing a comparison between a constant and an instruction that // can be folded into the comparison. if (ConstantInt *CI = dyn_cast<ConstantInt>(Op1)) { - Value *A = nullptr, *B = nullptr; // Since the RHS is a ConstantInt (CI), if the left hand side is an // instruction, see if that instruction also has constants so that the // instruction can be folded into the icmp @@ -3646,14 +3653,6 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) { if (Instruction *Res = foldICmpIntrinsicWithConstant(I, LHSI, CI)) return Res; } - // (icmp eq/ne (udiv A, B), 0) -> (icmp ugt/ule i32 B, A) - if (I.isEquality() && CI->isZero() && - match(Op0, m_UDiv(m_Value(A), m_Value(B)))) { - ICmpInst::Predicate Pred = I.getPredicate() == ICmpInst::ICMP_EQ - ? ICmpInst::ICMP_UGT - : ICmpInst::ICMP_ULE; - return new ICmpInst(Pred, B, A); - } } // Handle icmp with constant (but not simple integer constant) RHS |