[llvm] [LoopInterchange] Support inner-loop simple reductions via UndoSimpleReduction (PR #172970)

Sjoerd Meijer via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 6 03:02:55 PST 2026


================
@@ -475,9 +481,30 @@ class LoopInterchangeLegality {
     return HasNoWrapReductions;
   }
 
+  // Record the simple reduction in the inner loop.
+  struct SimpleReduction {
+    // The reduction itself;
+    PHINode *Re;
+    // So far only supports constant initial value.
+    Value *Init;
+    Value *Next;
+    // The Lcssa PHI
+    PHINode *LcssaPhi;
+    // Only supports one user for now
+    // Store reduction result into memory object
+    StoreInst *LcssaStorer;
----------------
sjoerdmeijer wrote:

Nit: not sure about the name "Storer", can we just call it LcssaStore instead?

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


More information about the llvm-commits mailing list