[clang] [ValueTracking] Simplify uaddo pattern (PR #65910)
Yingwei Zheng via cfe-commits
cfe-commits at lists.llvm.org
Sun Sep 24 02:09:46 PDT 2023
================
@@ -8291,6 +8291,29 @@ static std::optional<bool> isImpliedCondICmps(const ICmpInst *LHS,
if (L0 == R0 && match(L1, m_APInt(LC)) && match(R1, m_APInt(RC)))
return isImpliedCondCommonOperandWithConstants(LPred, *LC, RPred, *RC);
+ // L0 = R0 = L1 + R1, L0 >=u L1 implies R0 >=u R1, L0 <u L1 implies R0 <u R1
+ if (ICmpInst::isUnsigned(LPred) && ICmpInst::isUnsigned(RPred)) {
+ if (L0 == R1) {
+ std::swap(R0, R1);
+ RPred = ICmpInst::getSwappedPredicate(RPred);
+ }
+ if (L1 == R0) {
+ std::swap(L0, L1);
+ LPred = ICmpInst::getSwappedPredicate(LPred);
+ }
+ if (L1 == R1) {
+ std::swap(L0, L1);
+ LPred = ICmpInst::getSwappedPredicate(LPred);
+ std::swap(R0, R1);
+ RPred = ICmpInst::getSwappedPredicate(RPred);
+ }
+ if (L0 == R0 &&
+ (LPred == ICmpInst::ICMP_UGE || LPred == ICmpInst::ICMP_ULT) &&
----------------
dtcxzyw wrote:
It is not true for `L0 >u L1 -> R0 >u R1` and `L0 <=u L1 -> R0 <=u R1`.
Alive2: https://alive2.llvm.org/ce/z/VKtFkD
https://github.com/llvm/llvm-project/pull/65910
More information about the cfe-commits
mailing list