Issue 114656
Summary [mlir] Inconsistent results for memref.copy
Labels
Assignees
Reporter wangyongj1a
    I have the following MLIR program:
test.mlir:
```
module {
 func.func nested @func1() -> f32 {
    %idx0 = index.constant 0
 %idx1 = index.constant 1
    %true = arith.constant true
    %false = arith.constant false

    %alloc_33 = memref.alloc() : memref<11xi1>
    linalg.fill ins(%true : i1) outs(%alloc_33 : memref<11xi1>)

    %alloc_147 = memref.alloc() : memref<11xi1>    
 linalg.fill ins(%false : i1) outs(%alloc_147 : memref<11xi1>)

 memref.copy %alloc_147, %alloc_33 : memref<11xi1> to memref<11xi1>
 
    %dim = memref.dim %alloc_33, %idx0 : memref<11xi1>
    %0 = scf.for %arg1 = %idx0 to %dim step %idx1 iter_args(%arg2 = %false) -> (i1) {
      %1 = memref.load %alloc_33[%arg1] : memref<11xi1>
 vector.print %1 : i1
      %2 = arith.addi %arg2, %1 : i1
 scf.yield %2 : i1
    }
    
    vector.print %0 : i1
    %1 = arith.sitofp %0 : i1 to f32
    return %1 : f32
  }
}
```
When I ran ```/data/tmp/v1102/llvm-project/build/bin/mlir-opt --convert-vector-to-llvm --convert-linalg-to-loops --convert-scf-to-cf --finalize-memref-to-llvm --convert-arith-to-llvm --convert-func-to-llvm --convert-index-to-llvm --reconcile-unrealized-casts test.mlir | /data/tmp/v1102/llvm-project/build/bin/mlir-cpu-runner -e func1 --shared-libs=/data/tmp/v1102/llvm-project/build/lib/libmlir_runner_utils.so,/data/tmp/v1102/llvm-project/build/lib/libmlir_c_runner_utils.so``` on the program, I got the result of:
```
0
0
0
0
0
0
0
0
0
0
0
0
0.000000e+00
```
However, when I ran ```/data/tmp/v1102/llvm-project/build/bin/mlir-opt --test-linalg-transform-patterns=test-patterns --convert-vector-to-llvm --convert-linalg-to-loops --convert-scf-to-cf --finalize-memref-to-llvm --convert-arith-to-llvm --convert-func-to-llvm --convert-index-to-llvm --reconcile-unrealized-casts test.mlir | /data/tmp/v1102/llvm-project/build/bin/mlir-cpu-runner -e func1 --shared-libs=/data/tmp/v1102/llvm-project/build/lib/libmlir_runner_utils.so,/data/tmp/v1102/llvm-project/build/lib/libmlir_c_runner_utils.so``` on the program, I got the result of:
```
0
0
1
1
1
1
1
1
1
1
1
1
-1.000000e+00
```
The above two results seem to be inconsistent. I'm not sure if there is any bug in my program or if the wrong usage of the above passes caused these results.

My git version is 33bdb53d864e3e244d8fd5649062f17b7d4c958d.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to