[llvm] [ValueTracking] Extend LHS/RHS with matching operand to work without constants. (PR #85557)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 26 20:57:42 PDT 2024
================
@@ -8845,20 +8845,20 @@ isImpliedCondMatchingOperands(CmpInst::Predicate LPred,
return std::nullopt;
}
-/// Return true if "icmp LPred X, LC" implies "icmp RPred X, RC" is true.
-/// Return false if "icmp LPred X, LC" implies "icmp RPred X, RC" is false.
+/// Return true if "icmp LPred X, LCR" implies "icmp RPred X, RCR" is true.
+/// Return false if "icmp LPred X, LCR" implies "icmp RPred X, RCR" is false.
/// Otherwise, return std::nullopt if we can't infer anything.
-static std::optional<bool> isImpliedCondCommonOperandWithConstants(
- CmpInst::Predicate LPred, const APInt &LC, CmpInst::Predicate RPred,
- const APInt &RC) {
- ConstantRange DomCR = ConstantRange::makeExactICmpRegion(LPred, LC);
- ConstantRange CR = ConstantRange::makeExactICmpRegion(RPred, RC);
- ConstantRange Intersection = DomCR.intersectWith(CR);
- ConstantRange Difference = DomCR.difference(CR);
- if (Intersection.isEmptySet())
- return false;
- if (Difference.isEmptySet())
+static std::optional<bool> isImpliedCondCommonOperandWithCR(
+ CmpInst::Predicate LPred, const ConstantRange &LCR,
+ CmpInst::Predicate RPred, const ConstantRange &RCR) {
+ ConstantRange DomCR = ConstantRange::makeAllowedICmpRegion(LPred, LCR);
+ // If all true values for lhs and true for rhs, lhs implies rhs
+ if (DomCR.icmp(RPred, RCR))
----------------
goldsteinn wrote:
@nikic, did you comment a concern here then delete it, or is my github not updating properly? I see the email notification but nothing here.
https://github.com/llvm/llvm-project/pull/85557
More information about the llvm-commits
mailing list