Could index type be converted to the right type of index of affine load op

could index type be converted to the right type of index of affine.load.

The IR code as belowe, %1 cannot be the index of affine.load, so could it be converted to the right type of index of affine load op.

func @load_non_affine_index(%arg0 : index) {
  %0 = memref.alloc() : memref<10xf32>
  affine.for %i0 = 0 to 10 {
    %1 = arith.muli %i0, %arg0 : index
    // expected-error@+1 {{op index must be a dimension or symbol identifier}}
    %v = affine.load %0[%1] : memref<10xf32>
  }
  return
}

You can arith.index_cast the value

thanks @Mogball for help. but it seems that arith.index_cast can only cast between index type and scalar integer type, how should i cast the index type to the block argument type?

Affine load requires indices to be produced by the affine for loop. If you need to transform the index, you should do so with an affine map.

This question looks redundant with Affine.load op index must be a dimension or symbol identifier. Please make sure to read the documentation of the affine dialect, specifically the value categorization into dimensions, symbols and other values. The issue here is not about type but about that category.