[Mlir-commits] [mlir] 1fcfd5c - [mlir][amdgpu] Sink op creation in scaled conversion intrinsics (NFC) (#168542)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Nov 18 07:35:09 PST 2025
Author: Erick Ochoa Lopez
Date: 2025-11-18T10:35:05-05:00
New Revision: 1fcfd5c67bbabe5f134ef4268c2a890f2b0cfa0f
URL: https://github.com/llvm/llvm-project/commit/1fcfd5c67bbabe5f134ef4268c2a890f2b0cfa0f
DIFF: https://github.com/llvm/llvm-project/commit/1fcfd5c67bbabe5f134ef4268c2a890f2b0cfa0f.diff
LOG: [mlir][amdgpu] Sink op creation in scaled conversion intrinsics (NFC) (#168542)
Where possible:
* notifyMatchFailure happen first
* then op.emitOpError
* finally assertions / op creation.
---------
Co-authored-by: Jakub Kuderski <kubakuderski at gmail.com>
Added:
Modified:
mlir/lib/Conversion/AMDGPUToROCDL/AMDGPUToROCDL.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Conversion/AMDGPUToROCDL/AMDGPUToROCDL.cpp b/mlir/lib/Conversion/AMDGPUToROCDL/AMDGPUToROCDL.cpp
index edc6565f44f00..b9a5e7d7f6eac 100644
--- a/mlir/lib/Conversion/AMDGPUToROCDL/AMDGPUToROCDL.cpp
+++ b/mlir/lib/Conversion/AMDGPUToROCDL/AMDGPUToROCDL.cpp
@@ -1738,15 +1738,11 @@ LogicalResult ScaledExtPacked816OpLowering::matchAndRewrite(
auto sourceType = cast<VectorType>(op.getSource().getType());
auto srcElemType = cast<FloatType>(sourceType.getElementType());
unsigned bitWidth = srcElemType.getWidth();
- int32_t scaleSel =
- getScaleSel(blockSize, bitWidth, firstScaleLane, firstScaleByte);
auto targetType = cast<VectorType>(op.getResult().getType());
auto destElemType = cast<FloatType>(targetType.getElementType());
- IntegerType i32 = rewriter.getI32Type();
- Value castedScale =
- LLVM::BitcastOp::create(rewriter, loc, i32, adaptor.getScale());
+ IntegerType i32 = rewriter.getI32Type();
Value source = adaptor.getSource();
Type llvmResultType = typeConverter->convertType(op.getResult().getType());
Type packedType = nullptr;
@@ -1767,15 +1763,19 @@ LogicalResult ScaledExtPacked816OpLowering::matchAndRewrite(
return rewriter.notifyMatchFailure(op, "type conversion failed");
}
- Value castedSource =
- LLVM::BitcastOp::create(rewriter, loc, packedType, source);
-
std::optional<StringRef> maybeIntrinsic =
scaledExtPacked816ToIntrinsic(srcElemType, destElemType);
if (!maybeIntrinsic.has_value())
return op.emitOpError(
"no intrinsic matching packed scaled conversion on the given chipset");
+ int32_t scaleSel =
+ getScaleSel(blockSize, bitWidth, firstScaleLane, firstScaleByte);
+ Value castedScale =
+ LLVM::BitcastOp::create(rewriter, loc, i32, adaptor.getScale());
+ Value castedSource =
+ LLVM::BitcastOp::create(rewriter, loc, packedType, source);
+
OperationState loweredOp(loc, *maybeIntrinsic);
loweredOp.addTypes({llvmResultType});
loweredOp.addOperands({castedSource, castedScale});
More information about the Mlir-commits
mailing list