[all-commits] [llvm/llvm-project] 1a7af2: [mlir][DataLayout] Add `IsolatedFromAbove` to `Dat...
Fabian Mora via All-commits
all-commits at lists.llvm.org
Thu Mar 27 11:37:58 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 1a7af2a90fb043b25cbba15ce941ebfdba0e6717
https://github.com/llvm/llvm-project/commit/1a7af2a90fb043b25cbba15ce941ebfdba0e6717
Author: Fabian Mora <fmora.dev at gmail.com>
Date: 2025-03-27 (Thu, 27 Mar 2025)
Changed paths:
M mlir/include/mlir/Dialect/GPU/IR/GPUOps.td
M mlir/include/mlir/Interfaces/DataLayoutInterfaces.td
M mlir/test/lib/Dialect/Test/TestOps.td
Log Message:
-----------
[mlir][DataLayout] Add `IsolatedFromAbove` to `DataLayoutOpInterface` (#132742)
This patch adds the `IsolatedFromAbove` trait as a dependent trait to
the `DataLayoutOpInterface` op interface.
The motivation behind this change comes from the implementation of the
`ptr` dialect, specifically the `ptr.type_offset` op. This op produces
an int-like value that equates to the size of a memory element. This is
useful for ptr arithmetic and indexing arrays. For example:
```mlir
%f32_off = ptr.type_offset f32 : index
%addr = ptr.ptradd %ptr, %f32_off : !ptr, index
%x = ptr.load %addr : !ptr -> f32 // Read ptr[1]
```
Without the `IsolatedFromAvobe` trait in the DL interface, the
`ptr.type_offset` cannot be `ConstantLike`. Why?
Take the example:
```mlir
op {DL1} {
%f32_off0 = ptr.type_offset f32 : index
op {DL2} {
%f32_off1 = ptr.type_offset f32 : index
}
}
```
If `ptr.type_offset` were to be `ConstantLike` then `canonicalize` would
hoist and unique the value. However, that could be wrong as DL2 could
have an entry to specify the size that's different from the size in DL1.
The best solution to the above problem is to make
`DataLayoutOpInterface` require the `IsolatedFromAbove` trait, as it
preserves the constness of values in the DL with respect to the
canonicalizer.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list