diff options
author | Sanjay Patel <spatel@rotateright.com> | 2019-02-20 21:23:04 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2019-02-20 21:23:04 +0000 |
commit | 198cc305e985accb3ba74f64e38fd5b3146fe6f4 (patch) | |
tree | 74ed449a1f6500d3f3747747f006fa5f2aeea9e2 /llvm/lib/CodeGen/CodeGenPrepare.cpp | |
parent | 48cf37b55cc956df03c61bc41eb54fc4f582fef6 (diff) | |
download | llvm-198cc305e985accb3ba74f64e38fd5b3146fe6f4.zip llvm-198cc305e985accb3ba74f64e38fd5b3146fe6f4.tar.gz llvm-198cc305e985accb3ba74f64e38fd5b3146fe6f4.tar.bz2 |
[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
llvm-svn: 354519
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r-- | llvm/lib/CodeGen/CodeGenPrepare.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index 20a2ae1..e961139 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -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; |