[llvm] [IndVars] Rewrite loop-exit comparisons from operands (PR #223951)

Pengcheng Wang via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 22 23:18:27 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.
----------------
wangpc-pp wrote:

Done in https://github.com/llvm/llvm-project/pull/223951/commits/47a8e1dae88ab40c8c831fab2650993b638a9bd4.

https://github.com/llvm/llvm-project/pull/223951


More information about the llvm-commits mailing list