[llvm] [ValueTracking] Respect `samesign` flag in `isKnownInversion` (PR #112390)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 15 18:42:45 PDT 2024
================
@@ -8526,14 +8526,26 @@ bool llvm::isKnownInversion(const Value *X, const Value *Y) {
!match(Y, m_c_ICmp(Pred2, m_Specific(A), m_Value(C))))
return false;
+ // If they are only differ in predicate. They must both have samesign flag or
+ // not.
if (B == C)
- return Pred1 == ICmpInst::getInversePredicate(Pred2);
+ return Pred1 == ICmpInst::getInversePredicate(Pred2) &&
+ (!cast<ICmpInst>(X)->hasSameSign() ||
+ cast<ICmpInst>(Y)->hasSameSign());
----------------
dtcxzyw wrote:
Agree.
https://github.com/llvm/llvm-project/pull/112390
More information about the llvm-commits
mailing list