@@ -62,24 +62,30 @@ void buildCommonPassPipeline(
6262// ===----------------------------------------------------------------------===//
6363void buildGpuPassPipeline (OpPassManager &pm,
6464 const mlir::gpu::GPUToXeVMPipelineOptions &options) {
65- pm.addNestedPass <gpu::GPUModuleOp>(xegpu::createXeGPUWgToSgDistribute ());
66- pm.addNestedPass <gpu::GPUModuleOp>(createCSEPass ());
67- pm.addNestedPass <gpu::GPUModuleOp>(createLowerAffinePass ());
68- pm.addNestedPass <gpu::GPUModuleOp>(xegpu::createXeGPUBlocking ());
69- pm.addNestedPass <gpu::GPUModuleOp>(createCanonicalizerPass ());
70- pm.addNestedPass <gpu::GPUModuleOp>(createCSEPass ());
71- pm.addNestedPass <gpu::GPUModuleOp>(xegpu::createXeGPUPropagateLayout ());
72- pm.addNestedPass <gpu::GPUModuleOp>(xegpu::createXeGPUSubgroupDistribute ());
73- pm.addNestedPass <gpu::GPUModuleOp>(createCanonicalizerPass ());
74- pm.addNestedPass <gpu::GPUModuleOp>(createCSEPass ());
75- pm.addNestedPass <gpu::GPUModuleOp>(createLoopInvariantCodeMotionPass ());
76- pm.addNestedPass <gpu::GPUModuleOp>(createCSEPass ());
77- pm.addNestedPass <gpu::GPUModuleOp>(xegpu::createXeGPUVectorLinearize ());
65+ if (options.xegpuOpLevel == " workgroup" ) {
66+ pm.addNestedPass <gpu::GPUModuleOp>(xegpu::createXeGPUWgToSgDistribute ());
67+ pm.addNestedPass <gpu::GPUModuleOp>(createCSEPass ());
68+ pm.addNestedPass <gpu::GPUModuleOp>(createLowerAffinePass ());
69+ pm.addNestedPass <gpu::GPUModuleOp>(xegpu::createXeGPUBlocking ());
70+ pm.addNestedPass <gpu::GPUModuleOp>(createCanonicalizerPass ());
71+ pm.addNestedPass <gpu::GPUModuleOp>(createCSEPass ());
72+ }
73+ if (options.xegpuOpLevel == " subgroup" ) {
74+ pm.addNestedPass <gpu::GPUModuleOp>(xegpu::createXeGPUPropagateLayout ());
75+ pm.addNestedPass <gpu::GPUModuleOp>(xegpu::createXeGPUSubgroupDistribute ());
76+ pm.addNestedPass <gpu::GPUModuleOp>(createCanonicalizerPass ());
77+ pm.addNestedPass <gpu::GPUModuleOp>(createCSEPass ());
78+ pm.addNestedPass <gpu::GPUModuleOp>(createLoopInvariantCodeMotionPass ());
79+ pm.addNestedPass <gpu::GPUModuleOp>(createCSEPass ());
80+ pm.addNestedPass <gpu::GPUModuleOp>(xegpu::createXeGPUVectorLinearize ());
81+ }
7882 pm.addNestedPass <gpu::GPUModuleOp>(createConvertXeGPUToXeVMPass ());
79- ConvertGpuOpsToLLVMSPVOpsOptions gpuToLLVMSPVOptions;
80- gpuToLLVMSPVOptions.use64bitIndex = options.indexBitWidth ;
81- pm.addNestedPass <gpu::GPUModuleOp>(
82- createConvertGpuOpsToLLVMSPVOps (gpuToLLVMSPVOptions));
83+ {
84+ ConvertGpuOpsToLLVMSPVOpsOptions gpuToLLVMSPVOptions;
85+ gpuToLLVMSPVOptions.use64bitIndex = options.use64bitIndex ;
86+ pm.addNestedPass <gpu::GPUModuleOp>(
87+ createConvertGpuOpsToLLVMSPVOps (gpuToLLVMSPVOptions));
88+ }
8389 pm.addNestedPass <gpu::GPUModuleOp>(createConvertXeVMToLLVMPass ());
8490 pm.addNestedPass <gpu::GPUModuleOp>(createCSEPass ());
8591}
@@ -104,14 +110,14 @@ void buildHostPostPipeline(OpPassManager &pm,
104110 }
105111 pm.addPass (createConvertToLLVMPass ());
106112 pm.addPass (createLowerAffinePass ());
113+ pm.addPass (createReconcileUnrealizedCastsPass ());
107114 // gpu-module-to-binary
108115 {
109116 GpuModuleToBinaryPassOptions gpuToModuleBinOptions;
110117 gpuToModuleBinOptions.compilationTarget = options.binaryFormat ;
111118 gpuToModuleBinOptions.cmdOptions = options.cmdOptions ;
112119 pm.addPass (createGpuModuleToBinaryPass (gpuToModuleBinOptions));
113120 }
114- pm.addPass (createReconcileUnrealizedCastsPass ());
115121}
116122} // namespace
117123
0 commit comments