[Matrix] Add initial tiling for load/multiply/store chains.
authorFlorian Hahn <flo@fhahn.com>
Mon, 6 Apr 2020 08:24:03 +0000 (09:24 +0100)
committerFlorian Hahn <flo@fhahn.com>
Mon, 6 Apr 2020 08:28:15 +0000 (09:28 +0100)
commitd1fed7081d805e646bf19c047a95f581a90753cc
treefdcaad9c9acc969f8c19a2ec4f39b90be8a3a4d9
parentc2d03e4ef1412e434ba62fd071f76b65e9f0e666
[Matrix] Add initial tiling for load/multiply/store chains.

This patch adds initial fusion for load/multiply/store chains of matrix
operations.

The patch contains roughly two parts:

1. Code generation for a fused load/multiply/store chain (LowerMatrixMultiplyFused).
First, we ensure that both loads of the multiply operands do not alias the store.
If they do, we create new non-aliasing copies of the operands. Note that this
may introduce new basic block. Finally we process TileSize x TileSize blocks.
That is: load tiles from the input operands, multiply and store them.

2. Identify fusion candidates & matrix instructions.
As a first step, collect all instructions with shape info and fusion candidates
(currently @llvm.matrix.multiply calls). Next, try to fuse candidates and
collect instructions eliminated by fusion. Finally iterate over all matrix
instructions, skip the ones eliminated by fusion and lower the rest as usual.

Reviewers: anemet, Gerolf, hfinkel, andrew.w.kaylor, LuoYuanke

Reviewed By: anemet

Differential Revision: https://reviews.llvm.org/D75566
llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
llvm/test/Transforms/LowerMatrixIntrinsics/multiply-fused-multiple-blocks.ll [new file with mode: 0644]
llvm/test/Transforms/LowerMatrixIntrinsics/multiply-fused.ll [new file with mode: 0644]