[Mlir-commits] [mlir] [MLIR][XeGPU] Avoid round-trip convert_layout in layout conflict resolver (PR #229848)

Jianhui Li llvmlistbot at llvm.org
Sat Oct 17 22:29:24 PDT 2026


================
@@ -421,3 +421,202 @@ func.func @extract_source_conflict_with_order() -> vector<16x32xf16> {
   return %1 : vector<16x32xf16>
 }
 }
+
+
+// -----
+
+#inst_data_8x16 = #xegpu.layout<inst_data = [8, 16]>
+#inst_data_16x16 = #xegpu.layout<inst_data = [16, 16]>
+#inst_data_32x16 = #xegpu.layout<inst_data = [32, 16]>
+gpu.module @test_convert_chain_bypass {
+
+// Two users of the convert: exp wants [32, 16], sqrt wants [8, 16]. sqrt reads
+// the convert's source, the convert stays for exp, no [32, 16] -> [8, 16]
+// convert is inserted.
+// CHECK-LABEL: func.func @bypass_multi_use
+// CHECK:         %[[V0:.*]] = "some_op"() {layout_result_0 = #xegpu.layout<inst_data = [8, 16]>}
+// CHECK-NEXT:    %[[CVT:.*]] = xegpu.convert_layout %[[V0]]
+// CHECK-SAME:      <{input_layout = #xegpu.layout<inst_data = [8, 16]>, target_layout = #xegpu.layout<inst_data = [32, 16]>}>
+// CHECK-NEXT:    math.exp %[[CVT]]
+// CHECK-NOT:     xegpu.convert_layout
+// CHECK:         math.sqrt %[[V0]]
+// CHECK-SAME:      {layout_result_0 = #xegpu.layout<inst_data = [8, 16]>}
+// CHECK:         return
+func.func @bypass_multi_use() {
+  %0 = "some_op"() {layout_result_0 = #inst_data_8x16} : () -> vector<32x32xf16>
+  %1 = xegpu.convert_layout %0 <{input_layout = #inst_data_8x16, target_layout = #inst_data_32x16}> : vector<32x32xf16>
----------------
Jianhui-Li wrote:

I don't think we need to optimize this made-up cases. 
Please consider using xegpu dialect to construct meaningful high-perf kernel, and identify performance issue, and propose PRs. Thanks! @Naaz30 

https://github.com/llvm/llvm-project/pull/229848


More information about the Mlir-commits mailing list