[llvm] [Matrix] Propagate shape information through PHI insts (PR #141681)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 16 04:02:55 PDT 2025


================
@@ -2228,26 +2262,80 @@ class LowerMatrixIntrinsics {
   }
 
   /// Lower load instructions.
-  MatrixTy VisitLoad(LoadInst *Inst, const ShapeInfo &SI, Value *Ptr) {
-    IRBuilder<> Builder(Inst);
+  MatrixTy VisitLoad(LoadInst *Inst, const ShapeInfo &SI, Value *Ptr,
+                     IRBuilder<> &Builder) {
     return LowerLoad(Inst, Ptr, Inst->getAlign(),
-                     Builder.getInt64(SI.getStride()), Inst->isVolatile(), SI);
+                     Builder.getInt64(SI.getStride()), Inst->isVolatile(), SI,
+                     Builder);
   }
 
   MatrixTy VisitStore(StoreInst *Inst, const ShapeInfo &SI, Value *StoredVal,
-                      Value *Ptr) {
-    IRBuilder<> Builder(Inst);
+                      Value *Ptr, IRBuilder<> &Builder) {
     return LowerStore(Inst, StoredVal, Ptr, Inst->getAlign(),
-                      Builder.getInt64(SI.getStride()), Inst->isVolatile(), SI);
+                      Builder.getInt64(SI.getStride()), Inst->isVolatile(), SI,
+                      Builder);
+  }
+
+  MatrixTy VisitPHI(PHINode *Inst, const ShapeInfo &SI, IRBuilder<> &Builder) {
+    // Shim this->getMatrix to insert split phi's as needed.
+    auto getMatrix = [this, &Builder, SI](Value *MatrixVal) -> MatrixTy {
----------------
fhahn wrote:

```suggestion
    auto GetMatrix = [this, &Builder, SI](Value *MatrixVal) -> MatrixTy {
```

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


More information about the llvm-commits mailing list