[llvm] [IndVars] Rewrite loop-exit comparisons from operands (PR #223951)
Antonio Frighetto via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 21 06:04:30 PDT 2026
================
@@ -1790,25 +1791,31 @@ static bool hasHardUserWithinLoop(const Loop *L, const Instruction *I) {
return false;
}
+// Exit values of an instruction's loop-variant operands, indexed by operand
+// number.
+using OperandExitValueList = SmallVector<std::pair<unsigned, SCEVUse>, 2>;
+using ExpansionValue = std::variant<SCEVUse, OperandExitValueList>;
+
// Collect information about PHI nodes which can be transformed in
// rewriteLoopExitValues.
struct RewritePhi {
- PHINode *PN; // For which PHI node is this replacement?
- unsigned Ith; // For which incoming value?
- SCEVUse ExpansionSCEV; // The SCEV of the incoming value we are rewriting.
- Instruction *ExpansionPoint; // Where we'd like to expand that SCEV?
- bool HighCost; // Is this expansion a high-cost?
-
- RewritePhi(PHINode *P, unsigned I, SCEVUse Val, Instruction *ExpansionPt,
- bool H)
- : PN(P), Ith(I), ExpansionSCEV(Val), ExpansionPoint(ExpansionPt),
- HighCost(H) {}
+ PHINode *PN; // For which PHI node is this replacement?
+ unsigned Ith; // For which incoming value?
+ ExpansionValue ValueToExpand; // The incoming value or its varying operands.
----------------
antoniofrighetto wrote:
Do we need a std::variant? I think the code might look cleaner (and more idiomatic) if we keep having a SCEVUse here, and possibly add a `std::optional<OperandExitValueList>` instead.
https://github.com/llvm/llvm-project/pull/223951
More information about the llvm-commits
mailing list