[Mlir-commits] [mlir] [mlir] Add the concept of ASM dialect aliases (PR #86033)
Fabian Mora
llvmlistbot at llvm.org
Mon Mar 25 17:49:33 PDT 2024
fabianmcg wrote:
## Test
I used python to create a synthetic test:
```python
for i in range(0, 10000):
print("func.func @func{0}(%A: memref<?xi32, {0}>, %i: index) {{".format(i))
for j in range(0, 20):
print(" %{0} = memref.load %A[%i] : memref<?xi32, {1}>".format(j, i))
print(" memref.store %{0}, %A[%i] : memref<?xi32, {1}>".format(j, i))
print(" return")
print("}")
```
Which then I transformed to LLVM with:
```bash
mlir-opt test.mlir --finalize-memref-to-llvm --convert-func-to-llvm --canonicalize -o llvm.mlir
```
To get something that looks like:
```mlir
%0 = llvm.getelementptr %arg1[%arg5] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%1 = ptr.load %0 : !llvm.ptr -> i32
%2 = llvm.getelementptr %arg1[%arg5] : (!llvm.ptr, i64) -> !llvm.ptr, i32
ptr.store %1, %2 : i32, !llvm.ptr
```
and
```mlir
%0 = llvm.getelementptr %arg1[%arg5] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%1 = llvm.load %0 : !llvm.ptr -> i32
%2 = llvm.getelementptr %arg1[%arg5] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %1, %2 : i32, !llvm.ptr
```
for a total of `830003` lines.
Then I tested parse and printing times with:
```bash
mlir-opt llvm.mlir --mlir-timing -o llvm-other.mlir
```
Before the change:
```
Total Execution Time: 7.3231 seconds
----Wall Time---- ----Name----
6.1180 ( 83.5%) Parser
1.0906 ( 14.9%) Output
0.1144 ( 1.6%) Rest
7.3231 (100.0%) Total
```
After the change:
```
Total Execution Time: 5.3205 seconds
----Wall Time---- ----Name----
3.0505 ( 57.3%) Parser
2.1249 ( 39.9%) Output
0.1451 ( 2.7%) Rest
5.3205 (100.0%) Total
```
## Results
Parsing takes less time after change, without a good reason as to why. But printing does take 8% more after the change.
## Side note
While I was moving flang tests to use Ptr, I realized that this method has another flaw. Aliases are not always computed, for example, when emitting errors it prints the full version of the type.
https://github.com/llvm/llvm-project/pull/86033
More information about the Mlir-commits
mailing list