Skip to content
Draft
1 change: 1 addition & 0 deletions mlir/include/mlir/Dialect/Rock/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ namespace rock {
#define GEN_PASS_DECL_ROCKVIEWTOTRANSFORMPASS
#define GEN_PASS_DECL_ROCKDETECTFLASHDECODINGPASS
#define GEN_PASS_DECL_ROCKLOWERREDUCEPASS
#define GEN_PASS_DECL_ROCKREMOVEREDUNDANTCASTSPASS
#define GEN_PASS_DECL_ROCKPREPARELLVMPASS
#define GEN_PASS_DECL_ROCKCHECKRESIDENCYPASS
#define GEN_PASS_DECL_ROCKVECTORIZEFUSIONSPASS
Expand Down
14 changes: 14 additions & 0 deletions mlir/include/mlir/Dialect/Rock/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,20 @@ def RockLowerReducePass : Pass<"rock-lower-reduce", "::mlir::func::FuncOp"> {
let dependentDialects = ["rock::RockDialect", "func::FuncDialect", "gpu::GPUDialect"];
}

def RockRemoveRedundantCastsPass
: Pass<"rock-remove-redundant-casts", "::mlir::LLVM::LLVMFuncOp"> {
let summary = "Remove redundant fptrunc/fpext pairs through buffers at LLVM "
"dialect level";
let description = [{
Detects patterns at the LLVM dialect level where wider float values are
truncated (llvm.fptrunc) to a narrower type, stored to a buffer, then loaded
and extended (llvm.fpext) back to the original wider type. This pass
redirects the loads to read the wide values directly, eliminating the
fpext and preserving precision.
}];
let dependentDialects = ["LLVM::LLVMDialect"];
}

def RockPrepareLLVMPass : Pass<"rock-prepare-llvm", "::mlir::LLVM::LLVMFuncOp"> {
let summary = "prepare the generated code for llvm";
let dependentDialects = ["ROCDL::ROCDLDialect"];
Expand Down
1 change: 1 addition & 0 deletions mlir/lib/Dialect/Rock/Pipelines/Pipelines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ void rock::buildBackendPipeline(OpPassManager &pm,
// descriptors. (Mainly we want the `extractvalue` fold).
llvmFuncPm.addPass(createCanonicalizerPass());
llvmFuncPm.addPass(createCSEPass());
llvmFuncPm.addPass(rock::createRockRemoveRedundantCastsPass());
llvmFuncPm.addPass(rock::createRockPrepareLLVMPass());
if (options.compile) {
GpuROCDLAttachTargetOptions opts;
Expand Down
1 change: 1 addition & 0 deletions mlir/lib/Dialect/Rock/Transforms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ add_rocmlir_dialect_library(MLIRRockTransforms
BlockwiseLoadTileToThreadwise.cpp
AnnotateLiveness.cpp
AddAsyncWait.cpp
RemoveRedundantCasts.cpp
LowerRockOpsToROCDLOps.cpp

ADDITIONAL_HEADER_DIRS
Expand Down
Loading