Question about the normalize-memref pass failing on memref operations (original) (raw)
August 27, 2025, 5:17pm 1
#colmajor = affine_map<(d0,d1) -> (d0+5*d1)>
module {
func.func @main(%arg1 : memref<5x10xf64, #colmajor>, %arg2 : memref<10x5xf64>){
affine.for %i = 0 to 5{
affine.for %j = 0 to 10{
%test = memref.load %arg1[%i, %j] : memref<5x10xf64, #colmajor>
memref.store %test, %arg2[%j, %i] : memref<10x5xf64>
}
}
func.return
}
}
The normalize-memrefs pass fails on the above example with the following error:
error: 'memref.load' op incorrect number of indices for load, expected 1 but got 2
I have tried to understand why this is not allowed but I haven’t been able to figure it out. Does anyone know why using the pass in this context is not allowed?
Thanks!
Works for me at HEAD:
#map = affine_map<(d0, d1) -> (d0 + d1 * 5)>
module {
func.func @main(%arg0: memref<50xf64>, %arg1: memref<10x5xf64>) {
affine.for %arg2 = 0 to 5 {
affine.for %arg3 = 0 to 10 {
%0 = affine.apply #map(%arg2, %arg3)
%1 = memref.load %arg0[%0] : memref<50xf64>
memref.store %1, %arg1[%arg3, %arg2] : memref<10x5xf64>
}
}
return
}
}
Thank you for your reply! Is that the result after just applying “ –normalize-memrefs” ?
I am using llvm 19.1.0 so perhaps this was fixed since then.