[llvm] [ValueTracking] Infer relationship for the select with ICmp (PR #66668)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 6 09:31:39 PDT 2024
================
@@ -8883,6 +8883,26 @@ static std::optional<bool> isImpliedCondICmps(const ICmpInst *LHS,
if (L0 == R0 && L1 == R1)
return isImpliedCondMatchingOperands(LPred, RPred);
+ // It only really makes sense in the context of signed comparison for "X - Y
+ // must be positive if X >= Y and no overflow".
+ // Take SGT as an example: L0:x > L1:y and C >= 0
+ // ==> R0:(x -nsw y) < R1:(-C) is false
+ if ((LPred == ICmpInst::ICMP_SGT || LPred == ICmpInst::ICMP_SGE) &&
+ match(R0, m_NSWSub(m_Specific(L0), m_Specific(L1)))) {
+ if (match(R1, m_NonPositive()) &&
+ isImpliedCondMatchingOperands(LPred, RPred) == false)
+ return false;
+ }
----------------
goldsteinn wrote:
I made a mistake think this is okay.
https://github.com/llvm/llvm-project/pull/66668
More information about the llvm-commits
mailing list