Depends On D84933
The function is quite long but I did not think it would help clarity to split this up.
As soon as I can rebase to a revision that supports memref<?xindex> this will be gone (before this CL lands).
Looks good. memref<index> has landed upstream so please fix before landing.
nit: shapes has a different meaning for me. Maybe write !shape.shape to be explicit?