Issue 60921
Summary [MLIR] Failed to eliminate unrealized conversion casts
Labels new issue
Assignees
Reporter sweead
    Hello, I tried to use `-reconcile-unrealized-casts` to eliminate `builtin.unrealized_conversion_cast`, but i got an error.
IR:
```
module {
  func.func @vector_scalable_memcopy(%arg0: memref<?xf32>, %arg1: memref<?xf32>, %arg2: index) {
    %0 = builtin.unrealized_conversion_cast %arg0 : memref<?xf32> to !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<1 x i64>, array<1 x i64>)>
    %1 = builtin.unrealized_conversion_cast %arg1 : memref<?xf32> to !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<1 x i64>, array<1 x i64>)>
    %c0 = arith.constant 0 : index
    %c4 = arith.constant 4 : index
    %2 = "llvm.intr.vscale"() : () -> i64
    %3 = builtin.unrealized_conversion_cast %2 : i64 to index
    %4 = arith.muli %3, %c4 : index
    scf.for %arg3 = %c0 to %arg2 step %4 {
      %5 = builtin.unrealized_conversion_cast %arg3 : index to i64
      %6 = llvm.extractvalue %0[1] : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<1 x i64>, array<1 x i64>)>
      %7 = llvm.getelementptr %6[%5] : (!llvm.ptr<f32>, i64) -> !llvm.ptr<f32>
      %8 = llvm.bitcast %7 : !llvm.ptr<f32> to !llvm.ptr<vector<[4]xf32>>
      %9 = llvm.load %8 {alignment = 4 : i64} : !llvm.ptr<vector<[4]xf32>>
      %10 = llvm.extractvalue %1[1] : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<1 x i64>, array<1 x i64>)>
      %11 = llvm.getelementptr %10[%5] : (!llvm.ptr<f32>, i64) -> !llvm.ptr<f32>
      %12 = llvm.bitcast %11 : !llvm.ptr<f32> to !llvm.ptr<vector<[4]xf32>>
      llvm.store %9, %12 {alignment = 4 : i64} : !llvm.ptr<vector<[4]xf32>>
    }
    return
 }
}
```
Error message is like:
```
vector_scalable_memcopy.mlir:3:10: error: failed to legalize operation 'builtin.unrealized_conversion_cast' that was explicitly marked illegal
    %0 = builtin.unrealized_conversion_cast %arg0 : memref<?xf32> to !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<1 x i64>, array<1 x i64>)>
         ^
vector_scalable_memcopy.mlir:3:10: note: see current operation: %0 = "builtin.unrealized_conversion_cast"(%arg0) : (memref<?xf32>) -> !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<1 x i64>, array<1 x i64>)>
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to