[mlir] Fix scalable index handling and support scalable forall tiling (#235596)
Fixes https://github.com/llvm/llvm-project/issues/150203.
`tile_using_forall` accepts `tile_sizes [[8], 1]`, but the parser drops
the scalable flag and prints it back as `[8, 1]`. At `vscale = 2`, this
requests a tile size of 8 instead of 16. The bug changes the requested
tiling even when numerical results remain correct.
Preserve the flags in `scalable_sizes` and use the SCF tile-size
callback to materialize each nonzero scalable factor times
`vector.vscale`, after checking the target's tiling interface and tensor
semantics. Materialization happens separately for each payload target to
preserve SSA dominance across functions. Zero sizes remain untiled, and
omitted flags retain fixed-size behavior.
Parser overloads that cannot return scalable flags now diagnose scalable
indices instead of discarding them. Previously accepted markers in SCF
bounds and pack/unpack inner tiles are now rejected intentionally.
Ordinary fixed, dynamic SSA (including explicitly scaled values), and
packed lists keep their existing behavior. Scalable markers remain
unsupported in `num_threads` and packed tile size handles. The C++ and
Python builders accept scalable tile sizes.
Regression tests cover parsing/printing, invalid specifications, legacy
generic IR, Python builders, multiple targets, tail slices, mixed
dynamic sizes, and pack tiling with producer fusion. Tests for
suppressed failures on a non-tileable operation and memref pack/unpack
check that no tile-size IR is left behind, without running CSE or
canonicalization. For pack, the forall tile size is in the packed outer
iteration space; it scales independently of the pack's inner tile.
Validation:
- Assertions-enabled build: `ninja -C build-214281 check-mlir` passes
(4307 passed, 534 unsupported, 1 expected failure; no unexpected
failures).
- The original reproducer succeeds. Fixed/scalable IR specialization
checks pass at `vscale = 1, 2, 4`.
- QEMU AArch64: 15 numerical cases pass across `vscale = 1, 2, 4`.
- Native Redmi K70E (MediaTek Dimensity 8300-Ultra, Termux): 5 numerical
cases passed at `vscale = 1`, with zero mismatches. Regenerating the
numerical kernel after the callback refactor produces identical LLVM IR.
Execution checks serialize forall loops and check padding and partial
tiles. Wider vector lengths were tested under QEMU only.
Assisted-by: OpenAI Codex (6.1-sol)