This patch enables affine loop fusion for loops with affine vector loads
and stores. For that, we only had to use affine memory op interfaces in
LoopFusionUtils.cpp and Utils.cpp so that vector loads and stores are
also taken into account.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
This is really great - the same could be done for memref store to load forwarding, and it should work out of the box with affine.vector_load/store. But there's an issue with this (here and in general) if you mix vector load/stores with regular load/stores on the same memref. The slices computed by fusion aren't aware of the larger underlying loaded/stored data with the vectors. So the regions will be inaccurate at the boundaries. You are fine as long as you don't have memrefs that have both vector load/stores and scalar load/stores in different loop nests. With this patch, at the moment, if you mix the two, you'll get incorrect output from fusion say when the producer nest has scalar stores and the consumer vector loads. The slice won't have all the data needed.
This can be fixed by fixing the dependence information and memref region computation to account for vector load/stores. They would be inaccurate after this revision (and of course anyway inaccurate even if completely ignoring vector load/store).
Thanks Uday! Good point. I haven't looked too much into the slice computation but if you can send me some pointers and some examples on how the regions should be computed I could have a look. Thanks!