[llvm] [ValueTracking] Extend LHS/RHS with matching operand to work without constants. (PR #85557)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 17 23:07:15 PDT 2024
================
@@ -8676,20 +8676,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, ConstantRange LCR,
----------------
dtcxzyw wrote:
```suggestion
isImpliedCondCommonOperandWithCR(CmpInst::Predicate LPred, const ConstantRange &LCR,
```
https://github.com/llvm/llvm-project/pull/85557
More information about the llvm-commits
mailing list