[mlir][XeGPU] Add an SLM round-trip fallback for sg-to-lane convert_layout (#227884)
This PR adds a general fallback lowering for xegpu.convert_layout in the
sg-to-lane distribution pass, which round-trips the value through shared
local memory.
The existing lane-level lowerings are all special cases: the layouts
fold into each other, or they differ in a way a xegpu.lane_shuffle or a
gpu.shuffle can express. Anything else failed to legalize and stopped
the pipeline — for instance a conversion that only moves the lane_data
of a dimension distributed over part of the subgroup:
```mlir
xegpu.convert_layout %src
<{input_layout = #xegpu.layout<lane_layout = [1, 2, 8], lane_data = [1, 1, 4]>,
target_layout = #xegpu.layout<lane_layout = [1, 2, 8], lane_data = [1, 1, 1]>}>
: vector<1x2x32xbf16>
```
Here dim 2 is distributed over 8 of the 16 lanes and dim 1 over the
other factor of 2, so the subgroup splits into two groups that each hold
a run of their own. A single xegpu.lane_shuffle round-robins with a
stride of the whole subgroup size and cannot express that.
The new pattern works for any pair of layouts which can both distribute
the value: each lane writes its fragment to SLM at the coordinates
input_layout assigns it, then reads it back from the ones target_layout
assigns. It mirrors what XeGPUWgToSgDistribute already does for a
workgroup-level convert_layout whose sg_layout changes, and is
registered at a lower pattern benefit than every specialized lowering,
so it only runs once they have all declined.
assisted-by-claude
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
GitOrigin-RevId: 47d237ba0b8c8241d2fab80ba6709c4d5cbaaba7
See https://mlir.llvm.org/ for more information.