[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:14 PDT 2024
================
@@ -8729,11 +8729,30 @@ static std::optional<bool> isImpliedCondICmps(const ICmpInst *LHS,
}
}
- // Can we infer anything when the 0-operands match and the 1-operands are
- // constants (not necessarily matching)?
- const APInt *LC, *RC;
- if (L0 == R0 && match(L1, m_APInt(LC)) && match(R1, m_APInt(RC)))
- return isImpliedCondCommonOperandWithConstants(LPred, *LC, RPred, *RC);
+ // See if we can infer anything if operand-0 matches and we have at least one
+ // constant.
+ const APInt *Unused;
+ if (L0 == R0 && L0->getType()->isIntOrIntVectorTy() &&
+ (match(L1, m_APInt(Unused)) || match(R1, m_APInt(Unused)))) {
+ // Potential TODO: We could also further use the constant range of L0/R0 to
+ // further constraint the constant ranges. At the moment this leads to
+ // several regressions related to not transforming `multi_use(A + C0) eq/ne
+ // C1` (see discussion: D58633).
+ ConstantRange LCR = computeConstantRange(
+ L1, ICmpInst::isSigned(LPred), /* UseInstrInfo=*/true, /*AC=*/nullptr,
+ /*CxtI=*/nullptr, /*DT=*/nullptr, MaxAnalysisRecursionDepth - 1);
----------------
dtcxzyw wrote:
Should we pass `Depth` to `isImpliedCondICmps`?
https://github.com/llvm/llvm-project/pull/85557
More information about the llvm-commits
mailing list