[X86][AMX] Fix the shape dependency issue.
authorLuo, Yuanke <yuanke.luo@intel.com>
Mon, 14 Nov 2022 02:20:15 +0000 (10:20 +0800)
committerLuo, Yuanke <yuanke.luo@intel.com>
Wed, 16 Nov 2022 02:47:11 +0000 (10:47 +0800)
commit7d59b337f6dbeac3b0c655d52b7ce2edc4a2d364
treed72073d108dba828aa23d312c65dd130960723ee
parenta214c521f8763b36dd400b89017f74ad5ae4b6c7
[X86][AMX] Fix the shape dependency issue.

AMX shape should be defined before AMX intrinsics. However for below
case, the shape a.row is defined after tile load of b. If we transform
`load b` to `@llvm.x86.tileloadd64 intrinsic`, the shape dependency
doesn't meet.
```
void test_tile_dpbsud(__tile1024i a, __tile1024i b, __tile1024i c) {
  __tile_dpbsud(&c, a, b);
}
```
This patch is to store the tile b to stack and reloaded it after the
def of b.row. It would cause redundant store/load, but it is simple
to avoid generating invalid IR.
The better way may hoist `def b.row` before tile load instruction,
but it seems more complicated to recursively hoist its operands.

Differential Revision: https://reviews.llvm.org/D137923
llvm/lib/Target/X86/X86LowerAMXType.cpp
llvm/test/CodeGen/X86/AMX/amx-combine.ll