[CGP] match a special-case of unsigned subtract overflow

This is the 'sub0' (negate) pattern from PR31754:
https://bugs.llvm.org/show_bug.cgi?id=31754

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354519 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Sanjay Patel
2019-02-20 21:23:04 +00:00
parent 30f0c1109c
commit 1f63d705ea
3 changed files with 13 additions and 9 deletions
+5
View File
@@ -1228,6 +1228,11 @@ static bool combineToUSubWithOverflow(CmpInst *Cmp, const TargetLowering &TLI,
B = ConstantInt::get(B->getType(), 1);
Pred = ICmpInst::ICMP_ULT;
}
// Convert special-case: (A != 0) is the same as (0 u< A).
if (Pred == ICmpInst::ICMP_NE && match(B, m_ZeroInt())) {
std::swap(A, B);
Pred = ICmpInst::ICMP_ULT;
}
if (Pred != ICmpInst::ICMP_ULT)
return false;