[PATCH] D149510: [InstSimplify] add UGT and UGE case in isImpliedCondOperands
Zhu Siyuan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 28 23:29:34 PDT 2023
floatshadow created this revision.
floatshadow added reviewers: nikic, RKSimon, spatel.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
floatshadow requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
try to fix https://github.com/llvm/llvm-project/issues/62441
the two ugt icmp is not fold as `isImpliedCondOperands` only handles less cases.
alive2 proof: https://alive2.llvm.org/ce/z/jLFDAv
other cases like https://github.com/llvm/llvm-project/issues/61393 might take into consideration.
https://reviews.llvm.org/D149510
Files:
llvm/lib/Analysis/ValueTracking.cpp
Index: llvm/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/lib/Analysis/ValueTracking.cpp
+++ llvm/lib/Analysis/ValueTracking.cpp
@@ -7938,6 +7938,10 @@
// LHS u<= LHS +_{nuw} C for any C
if (match(RHS, m_NUWAdd(m_Specific(LHS), m_APInt(C))))
return true;
+
+ // (RHS >> X) u<= RHS for any X
+ if (match(LHS, m_LShr(m_Specific(RHS), m_Value())))
+ return true;
// Match A to (X +_{nuw} CA) and B to (X +_{nuw} CB)
auto MatchNUWAddsToSameValue = [&](const Value *A, const Value *B,
@@ -7993,6 +7997,13 @@
isTruePredicate(CmpInst::ICMP_ULE, ARHS, BRHS, DL, Depth))
return true;
return std::nullopt;
+
+ case CmpInst::ICMP_UGT:
+ case CmpInst::ICMP_UGE:
+ if (isTruePredicate(CmpInst::ICMP_ULE, ALHS, BLHS, DL, Depth) &&
+ isTruePredicate(CmpInst::ICMP_ULE, BRHS, ARHS, DL, Depth))
+ return true;
+ return std::nullopt;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149510.518132.patch
Type: text/x-patch
Size: 986 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230429/3f082e03/attachment.bin>
More information about the llvm-commits
mailing list