Skip to content

[mlir][ArmSME] Remove func patterns from vector lowering #121640

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

matthias-springer
Copy link
Member

@matthias-springer matthias-springer commented Jan 4, 2025

Remove func.call and func.return patterns from populateArmSVELegalizeForLLVMExportPatterns. This function is called from ConvertVectorToLLVMPass::runOnOperation. That pass should lower only vector dialect ops, not func dialect ops. These patterns also seem to be unnecessary, as no test cases are failing without them. Also note that there is no func.func pattern, so any application of the above-mentioned patterns produces invalid IR.

Remove `func.call` and `func.return` patterns from `populateArmSVELegalizeForLLVMExportPatterns`. This function is called from `ConvertVectorToLLVMPass::runOnOperation`. That pass should lower `vector` dialect ops, not `func` dialect ops. These patterns also seem to be unnecessary, as no test cases are failing without them.
@llvmbot
Copy link
Member

llvmbot commented Jan 4, 2025

@llvm/pr-subscribers-mlir-sve

@llvm/pr-subscribers-mlir

Author: Matthias Springer (matthias-springer)

Changes

Remove func.call and func.return patterns from populateArmSVELegalizeForLLVMExportPatterns. This function is called from ConvertVectorToLLVMPass::runOnOperation. That pass should lower vector dialect ops, not func dialect ops. These patterns also seem to be unnecessary, as no test cases are failing without them.


Full diff: https://github.com/llvm/llvm-project/pull/121640.diff

1 Files Affected:

  • (modified) mlir/lib/Dialect/ArmSVE/Transforms/LegalizeForLLVMExport.cpp (-20)
diff --git a/mlir/lib/Dialect/ArmSVE/Transforms/LegalizeForLLVMExport.cpp b/mlir/lib/Dialect/ArmSVE/Transforms/LegalizeForLLVMExport.cpp
index 845a32c4d97b5e..2bdb640699d036 100644
--- a/mlir/lib/Dialect/ArmSVE/Transforms/LegalizeForLLVMExport.cpp
+++ b/mlir/lib/Dialect/ArmSVE/Transforms/LegalizeForLLVMExport.cpp
@@ -20,22 +20,6 @@
 using namespace mlir;
 using namespace mlir::arm_sve;
 
-template <typename OpTy>
-class ForwardOperands : public OpConversionPattern<OpTy> {
-  using OpConversionPattern<OpTy>::OpConversionPattern;
-
-  LogicalResult
-  matchAndRewrite(OpTy op, typename OpTy::Adaptor adaptor,
-                  ConversionPatternRewriter &rewriter) const final {
-    if (adaptor.getOperands().getTypes() == op->getOperands().getTypes())
-      return rewriter.notifyMatchFailure(op, "operand types already match");
-
-    rewriter.modifyOpInPlace(op,
-                             [&]() { op->setOperands(adaptor.getOperands()); });
-    return success();
-  }
-};
-
 using SdotOpLowering = OneToOneConvertToLLVMPattern<SdotOp, SdotIntrOp>;
 using SmmlaOpLowering = OneToOneConvertToLLVMPattern<SmmlaOp, SmmlaIntrOp>;
 using UdotOpLowering = OneToOneConvertToLLVMPattern<UdotOp, UdotIntrOp>;
@@ -204,10 +188,6 @@ void mlir::populateArmSVELegalizeForLLVMExportPatterns(
   // Populate conversion patterns
 
   // clang-format off
-  patterns.add<ForwardOperands<func::CallOp>,
-               ForwardOperands<func::CallIndirectOp>,
-               ForwardOperands<func::ReturnOp>>(converter,
-                                          &converter.getContext());
   patterns.add<SdotOpLowering,
                SmmlaOpLowering,
                UdotOpLowering,

Copy link
Contributor

@banach-space banach-space left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pre-dates my involvement with SVE in MLIR, but makes total sense. LGTM and thanks for the clean-up 🙏🏻

These patterns also seem to be unnecessary, as no test cases are failing without them.

I suspect that you are skipping the SVE and SME integration tests? Those are DISABLED by default and also not included in pre-merge CI. Still, it should be safe to land this. I'd only recommend to track these bots that run the SVE+SME e2e tests:

@matthias-springer matthias-springer merged commit 2dcb3b9 into main Jan 5, 2025
11 checks passed
@matthias-springer matthias-springer deleted the users/matthias-springer/arm_vec_func_patterns branch January 5, 2025 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants