llvm.org GIT mirror llvm / fca9c7b
InstSimplify: Try to bring back the rest of r223583 This reverts r223624 with a small tweak, hopefully this will make stage3 equivalent. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223679 91177308-0d34-0410-b5e6-96231b3b80d8 David Majnemer 4 years ago
2 changed file(s) with 16 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
14471447 Value *X, *Y;
14481448
14491449 ICmpInst::Predicate EqPred;
1450 if (!match(ZeroICmp, m_ICmp(EqPred, m_Value(Y), m_Zero())) &&
1451 ICmpInst::isEquality(EqPred))
1450 if (!match(ZeroICmp, m_ICmp(EqPred, m_Value(Y), m_Zero())) ||
1451 !ICmpInst::isEquality(EqPred))
14521452 return nullptr;
14531453
14541454 ICmpInst::Predicate UnsignedPred;
14741474 return getTrue(UnsignedICmp->getType());
14751475 return UnsignedICmp;
14761476 }
1477
1478 // X < Y && Y == 0 --> false
1479 if (UnsignedPred == ICmpInst::ICMP_ULT && EqPred == ICmpInst::ICMP_EQ &&
1480 IsAnd)
1481 return getFalse(UnsignedICmp->getType());
14771482
14781483 return nullptr;
14791484 }
165165 ; CHECK: %[[cmp:.*]] = icmp ult i32 %x, %y
166166 ; CHECK: ret i1 %[[cmp]]
167167
168 define i1 @and_icmp2(i32 %x, i32 %y) {
169 %1 = icmp ult i32 %x, %y
170 %2 = icmp eq i32 %y, 0
171 %3 = and i1 %1, %2
172 ret i1 %3
173 }
174 ; CHECK-LABEL: @and_icmp2(
175 ; CHECK: ret i1 false
176
168177 define i1 @or_icmp1(i32 %x, i32 %y) {
169178 %1 = icmp ult i32 %x, %y
170179 %2 = icmp ne i32 %y, 0