[Mlir-commits] [mlir] [mlir][vector] Hoist transfer pairs when the source is AssumeAlignmentOp (PR #144809)
Han-Chung Wang
llvmlistbot at llvm.org
Thu Jun 19 13:55:43 PDT 2025
hanhanW wrote:
> Isn't the new behaviour correct? I might be mistaken, but to me this creates an alias:
>
> ```mlir
> %assume_align = memref.assume_alignment %memref0, 64 : memref<?x?xf32>
> ```
>
> Without proper alias-analysis, the logic updated in this PR should behave conservatively, i.e. block hoisting. When `memref.assume_alignment` didn't return a value, there was no alias and hoisting was safe. But that's no longer the case.
What alias-analysis is needed for doing the hoisting?
>
> To me the lack of hoisting feels like quite an unfortunate side-effect of [ffb9bbf](https://github.com/llvm/llvm-project/commit/ffb9bbfd0745dc22e1fd6edd7b62f72b91f4f6de).
>
> WDYT?
I'm not sure what the proper fix is, and suggestions are welcome. Let me unpack more context, [ffb9bbf](https://github.com/llvm/llvm-project/commit/ffb9bbfd0745dc22e1fd6edd7b62f72b91f4f6de) breaks a set of tests in our downstream project. The reason is that it disables hoisting on memrefs when memref.assume_alignment is involved. It means that we'll never be able to hoist vectors on memrefs without a fix.
If the vectorization and hoisting happen at tensor level, there are no issues. However, some compilers are not tensor based compiler. They can decide to do vectorization and hoisting on memrefs. Hoisting is an important feature in optimization. I think we need to support memref.assume_alignment somehow.
The intention of memref.assume_alignment is allowing the compiler to generate more efficient code based on the alignment assumption; it returns the same buffer with the alignment assumption. I think it is a special ViewLikeOp. Should I check the source of assume_alignment is ViewLikeOpInterface instead?
The author mentioned that it's fine to remove ViewLikeOpInterface from the op, but I agree with you that it creates an alias. So maybe we want to keep the interface? https://github.com/llvm/llvm-project/pull/139521#issuecomment-2886458733
https://github.com/llvm/llvm-project/pull/144809
More information about the Mlir-commits
mailing list