[Mlir-commits] [mlir] [mlir][MemRef] Changed AssumeAlignment into a Pure ViewLikeOp (PR #139521)

Matthias Springer llvmlistbot at llvm.org
Thu May 15 15:45:06 PDT 2025


================
@@ -142,22 +142,41 @@ class AllocLikeOp<string mnemonic,
 // AssumeAlignmentOp
 //===----------------------------------------------------------------------===//
 
-def AssumeAlignmentOp : MemRef_Op<"assume_alignment"> {
+def AssumeAlignmentOp : MemRef_Op<"assume_alignment", [
+      DeclareOpInterfaceMethods<OpAsmOpInterface, ["getAsmResultNames"]>,
+      Pure, 
+      ViewLikeOpInterface,
+      SameOperandsAndResultType
+    ]> {
   let summary =
       "assertion that gives alignment information to the input memref";
   let description = [{
-    The `assume_alignment` operation takes a memref and an integer of alignment
-    value, and internally annotates the buffer with the given alignment. If
-    the buffer isn't aligned to the given alignment, the behavior is undefined.
+      The `assume_alignment` operation takes a memref and an integer of alignment
+      value. It returns a new SSA value of the same memref type, but associated
+      with the assertion that the underlying buffer is aligned to the given
+      alignment. 
 
-    This operation doesn't affect the semantics of a correct program. It's for
-    optimization only, and the optimization is best-effort.
+      If the buffer isn't aligned to the given alignment, this operation
+      itself does not cause undefined behavior. However, subsequent operations
+      that consume the resulting memref and rely on this asserted alignment for
----------------
matthias-springer wrote:

`rely on the specified alignment`

https://github.com/llvm/llvm-project/pull/139521


More information about the Mlir-commits mailing list