[PATCH] D83570: [Matrix] Lowering pass should also run at O0

Sjoerd Meijer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 10 09:32:15 PDT 2020


SjoerdMeijer created this revision.
SjoerdMeijer added reviewers: fhahn, anemet, Gerolf.
Herald added subscribers: tschuett, hiraditya.
Herald added a project: LLVM.

As the Matrix intrinsic lowering pass is not running at -O0, code using the matrix extension results in a backend crash.


https://reviews.llvm.org/D83570

Files:
  clang/test/CodeGen/matrix-lowering.c
  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
@@ -531,6 +531,9 @@
       // new unnamed globals.
       MPM.add(createNameAnonGlobalPass());
     }
+    // Matrix intrinsics need to lowered also at -O0, but don't run CSE as a
+    // clean-up after it, which we do with OptLevel > 0.
+    MPM.add(createLowerMatrixIntrinsicsPass());
     return;
   }
 
Index: clang/test/CodeGen/matrix-lowering.c
===================================================================
--- /dev/null
+++ clang/test/CodeGen/matrix-lowering.c
@@ -0,0 +1,21 @@
+// RUN: %clang -O0 -fenable-matrix -target aarch64-linux-eabi %s -S -emit-llvm -o - | FileCheck  %s
+// RUN: %clang -O1 -fenable-matrix -target aarch64-linux-eabi %s -S -emit-llvm -o - | FileCheck  %s
+// RUN: %clang -O2 -fenable-matrix -target aarch64-linux-eabi %s -S -emit-llvm -o - | FileCheck  %s
+// RUN: %clang -O3 -fenable-matrix -target aarch64-linux-eabi %s -S -emit-llvm -o - | FileCheck  %s
+// RUN: %clang -Ofast -fenable-matrix -target aarch64-linux-eabi %s -S -emit-llvm -o - | FileCheck  %s
+// RUN: %clang -Os -fenable-matrix -target aarch64-linux-eabi %s -S -emit-llvm -o - | FileCheck  %s
+// RUN: %clang -Oz -fenable-matrix -target aarch64-linux-eabi %s -S -emit-llvm -o - | FileCheck  %s
+
+// CHECK-NOT: @llvm.matrix.multiply
+
+typedef float m4x4_t __attribute__((matrix_type(4, 4)));
+
+m4x4_t f(m4x4_t a, m4x4_t b, m4x4_t c) {
+//
+// CHECK-LAVEL: f(
+// CHECK-NOT:     @llvm.matrix.multiply
+// CHECK:       }
+//
+  return a + b * c;
+}
+


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83570.277075.patch
Type: text/x-patch
Size: 1682 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200710/0f3a9d10/attachment.bin>


More information about the llvm-commits mailing list