llvm.org GIT mirror llvm / f5783f8
Repair a transform that Chris noticed a bug in. Thanks to Nicholas for pointing out my stupid mistakes when writing this patch. :-) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45384 91177308-0d34-0410-b5e6-96231b3b80d8 Owen Anderson 11 years ago
1 changed file(s) with 12 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
48344834 if (ConstantInt *CI = dyn_cast(Op1)) {
48354835 Value *A, *B;
48364836
4837 #if 0
4838 // (icmp cond (sub A B) 0) -> (icmp cond A B)
4839 if (CI->isNullValue() && match(Op0, m_Sub(m_Value(A), m_Value(B))))
4840 return new ICmpInst(I.getPredicate(), A, B);
4841 #endif
4837 // (icmp cond (sub A B) 0) -> ...
4838 if (CI->isNullValue() && match(Op0, m_Sub(m_Value(A), m_Value(B)))) {
4839 // (icmp cond A B) if cond is signed or equality
4840 if (CmpInst::isSigned(I.getPredicate()) || I.isEquality())
4841 return new ICmpInst(I.getPredicate(), A, B);
4842 // (icmp ne A B) if cond is ugt
4843 else if (I.getPredicate() == ICmpInst::ICMP_UGT)
4844 return new ICmpInst(ICmpInst::ICMP_NE, A, B);
4845 // (icmp eq A B) if cond is ule
4846 else if (I.getPredicate() == ICmpInst::ICMP_ULE)
4847 return new ICmpInst(ICmpInst::ICMP_EQ, A, B);
4848 }
48424849
48434850 switch (I.getPredicate()) {
48444851 default: break;