I can’t understand what I’m doing wrong when using the vector_load operation from the Affine dialect.
This works fine and prints ( 10, 23, 57 ), which are the elements I store in the i32 memref:
// RUN: mlir-opt %s -lower-affine -convert-vector-to-llvm | \
// RUN: mlir-cpu-runner -e main -entry-point-result=void \
// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_c_runner_utils%shlibext
func @main() -> () {
%mem = alloca() : memref<3xi32>
%c0 = constant 0 : index
%c1 = constant 1 : index
%c2 = constant 2 : index
%c10 = constant 10 : i32
%c23 = constant 23 : i32
%c57 = constant 57 : i32
store %c10, %mem[%c0] : memref<3xi32>
store %c23, %mem[%c1] : memref<3xi32>
store %c57, %mem[%c2] : memref<3xi32>
%v = affine.vector_load %mem[0] : memref<3xi32>, vector<3xi32>
vector.print %v : vector<3xi32>
return
}
This prints ( 0, 0, 0 ), instead of the supposed ( 0, 1, 1 ). The only difference is the element type, which is i1 instead of i32:
// RUN: mlir-opt %s -lower-affine -convert-vector-to-llvm | \
// RUN: mlir-cpu-runner -e main -entry-point-result=void \
// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_c_runner_utils%shlibext
func @main() -> () {
%mem = alloca() : memref<3xi1>
%c0 = constant 0 : index
%c1 = constant 1 : index
%c2 = constant 2 : index
%true = constant true
%false = constant false
store %false, %mem[%c0] : memref<3xi1>
store %true, %mem[%c1] : memref<3xi1>
store %true, %mem[%c2] : memref<3xi1>
%v = affine.vector_load %mem[0] : memref<3xi1>, vector<3xi1>
vector.print %v : vector<3xi1>
return
}
Is there something wrong in my code or is it a bug?