[llvm] [ValueTracking] Respect `samesign` flag in `isKnownInversion` (PR #112390)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 15 10:49:38 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());
----------------
nikic wrote:
Can we check hasSameSign() == hasSameSign() instead? I'm somewhat uncomfortable with making this asymmetric, as it's not obvious from the isKnownInversion() API that the order of arguments would matter in any way.
https://github.com/llvm/llvm-project/pull/112390
More information about the llvm-commits
mailing list