[MLIR][Linalg] Fix crash in tileToForallOpImpl for rank-0 ops (#189000)
When tiling a rank-0 linalg.generic op, tileUsingSCF returns an empty
loops vector (rank-0 ops have no parallel dimensions and produce no
scf.forall). Two call sites unconditionally accessed
tilingResult.loops.front(), causing a crash:
- tileToForallOpImpl: the loop normalization block was entered whenever
mixedNumThreads was empty, regardless of whether any loops exist. Guard
it with \!tilingResult.loops.empty().
- TileUsingForallOp::apply: tileOps.push_back was called
unconditionally. Guard it with \!tilingResult.loops.empty().
Add regression tests for both the tile_sizes and num_threads paths,
verifying that the linalg.generic is preserved and no scf.forall is
emitted.
Fixes #187073
Assisted-by: Claude Code