[PATCH] D102496: [Passes] Run vector-combine early with -fenable-matrix.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 14 06:50:48 PDT 2021


fhahn created this revision.
fhahn added reviewers: anemet, spatel, RKSimon.
Herald added a subscriber: hiraditya.
fhahn requested review of this revision.
Herald added a project: LLVM.

IR with matrix intrinsics is likely to also contain large vector
operations, which can benefit from early simplifications.

This is the last step in a series of changes to improve code-gen for
code using matrix subscript operators with the C/C++ matrix extension in
CLang, like

  using matrix_t = double __attribute__((matrix_type(15, 15)));
  
  void foo(unsigned i, matrix_t &A, matrix_t &B) {
    for (unsigned j = 0; j < 4; ++j)
      for (unsigned k = 0; k < i; k++)
        B[k][j] -= A[k][j] * B[i][j];
  }

https://clang.godbolt.org/z/6dKxK1Ed7


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102496

Files:
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/IPO/PassManagerBuilder.cpp


Index: llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
===================================================================
--- llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
+++ llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
@@ -427,6 +427,11 @@
   MPM.add(createCFGSimplificationPass());      // Merge & remove BBs
   MPM.add(createReassociatePass());           // Reassociate expressions
 
+  // The matrix extension can introduce large vector operations early, which can
+  // benefit from running vector-combine early on.
+  if (EnableMatrix)
+    MPM.add(createVectorCombinePass());
+
   // Begin the loop pass pipeline.
   if (EnableSimpleLoopUnswitch) {
     // The simple loop unswitch pass relies on separate cleanup passes. Schedule
Index: llvm/lib/Passes/PassBuilder.cpp
===================================================================
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -807,6 +807,11 @@
   // Delete small array after loop unroll.
   FPM.addPass(SROA());
 
+  // The matrix extension can introduce large vector operations early, which can
+  // benefit from running vector-combine early on.
+  if (EnableMatrix)
+    FPM.addPass(VectorCombinePass());
+
   // Eliminate redundancies.
   FPM.addPass(MergedLoadStoreMotionPass());
   if (RunNewGVN)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102496.345429.patch
Type: text/x-patch
Size: 1301 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210514/ac02a475/attachment.bin>


More information about the llvm-commits mailing list