Skip to content

Commit 53d080c

Browse files
[mlir][Arith] Remove arith-to-llvm from func-to-llvm (#120548)
Do not run `arith-to-llvm` as part of `func-to-llvm`. This commit partly fixes #70982. Also simplify the pass pipeline for two math dialect integration tests. Note for LLVM integration: If you see failures, add `arith-to-llvm` to your pass pipeline.
1 parent 701f240 commit 53d080c

File tree

7 files changed

+9
-5
lines changed

7 files changed

+9
-5
lines changed

mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,6 @@ struct ConvertFuncToLLVMPass
787787

788788
// TODO(https://github.com/llvm/llvm-project/issues/70982): Remove these in
789789
// favor of their dedicated conversion passes.
790-
arith::populateArithToLLVMConversionPatterns(typeConverter, patterns);
791790
cf::populateControlFlowToLLVMConversionPatterns(typeConverter, patterns);
792791

793792
LLVMConversionTarget target(getContext());

mlir/test/Dialect/ArmSVE/legalize-for-llvm.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: mlir-opt -convert-vector-to-llvm="enable-arm-sve" -convert-func-to-llvm -cse -reconcile-unrealized-casts -split-input-file %s | FileCheck %s
1+
// RUN: mlir-opt -convert-vector-to-llvm="enable-arm-sve" -convert-func-to-llvm -convert-arith-to-llvm -cse -reconcile-unrealized-casts -split-input-file %s | FileCheck %s
22

33
func.func @arm_sve_sdot(%a: vector<[16]xi8>,
44
%b: vector<[16]xi8>,

mlir/test/lib/Dialect/LLVM/TestLowerToLLVM.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
//===----------------------------------------------------------------------===//
1313

1414
#include "mlir/Conversion/AffineToStandard/AffineToStandard.h"
15+
#include "mlir/Conversion/ArithToLLVM/ArithToLLVM.h"
1516
#include "mlir/Conversion/FuncToLLVM/ConvertFuncToLLVMPass.h"
1617
#include "mlir/Conversion/IndexToLLVM/IndexToLLVM.h"
1718
#include "mlir/Conversion/MathToLLVM/MathToLLVM.h"
@@ -73,6 +74,8 @@ void buildTestLowerToLLVM(OpPassManager &pm,
7374
pm.addPass(createFinalizeMemRefToLLVMConversionPass());
7475
// Convert Func to LLVM (always needed).
7576
pm.addPass(createConvertFuncToLLVMPass());
77+
// Convert Arith to LLVM (always needed).
78+
pm.addPass(createArithToLLVMConversionPass());
7679
// Convert Index to LLVM (always needed).
7780
pm.addPass(createConvertIndexToLLVMPass());
7881
// Convert remaining unrealized_casts (always needed).

mlir/test/mlir-cpu-runner/math-polynomial-approx.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: mlir-opt %s -pass-pipeline="builtin.module(func.func(test-math-polynomial-approximation,convert-arith-to-llvm),convert-vector-to-scf,convert-scf-to-cf,convert-cf-to-llvm,convert-vector-to-llvm,func.func(convert-math-to-llvm),convert-func-to-llvm,reconcile-unrealized-casts)" \
1+
// RUN: mlir-opt %s -pass-pipeline="builtin.module(func.func(test-math-polynomial-approximation),convert-vector-to-scf,convert-scf-to-cf,convert-vector-to-llvm,convert-to-llvm,reconcile-unrealized-casts)" \
22
// RUN: | mlir-cpu-runner \
33
// RUN: -e main -entry-point-result=void -O0 \
44
// RUN: -shared-libs=%mlir_c_runner_utils \

mlir/test/mlir-cpu-runner/test-expand-math-approx.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: mlir-opt %s -pass-pipeline="builtin.module(func.func(test-expand-math,convert-arith-to-llvm),convert-vector-to-scf,convert-scf-to-cf,convert-cf-to-llvm,convert-vector-to-llvm,func.func(convert-math-to-llvm),convert-func-to-llvm,reconcile-unrealized-casts)" \
1+
// RUN: mlir-opt %s -pass-pipeline="builtin.module(func.func(test-expand-math),convert-vector-to-scf,convert-scf-to-cf,convert-vector-to-llvm,convert-to-llvm,reconcile-unrealized-casts)" \
22
// RUN: | mlir-cpu-runner \
33
// RUN: -e main -entry-point-result=void -O0 \
44
// RUN: -shared-libs=%mlir_c_runner_utils \

mlir/test/python/execution_engine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def testInvalidModule():
7474

7575
def lowerToLLVM(module):
7676
pm = PassManager.parse(
77-
"builtin.module(convert-complex-to-llvm,finalize-memref-to-llvm,convert-func-to-llvm,reconcile-unrealized-casts)"
77+
"builtin.module(convert-complex-to-llvm,finalize-memref-to-llvm,convert-func-to-llvm,convert-arith-to-llvm,reconcile-unrealized-casts)"
7878
)
7979
pm.run(module.operation)
8080
return module

mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15+
#include "mlir/Conversion/ArithToLLVM/ArithToLLVM.h"
1516
#include "mlir/Conversion/FuncToLLVM/ConvertFuncToLLVMPass.h"
1617
#include "mlir/Conversion/GPUToVulkan/ConvertGPUToVulkanPass.h"
1718
#include "mlir/Conversion/LLVMCommon/LoweringOptions.h"
@@ -55,6 +56,7 @@ static LogicalResult runMLIRPasses(Operation *op, JitRunnerOptions &) {
5556
funcToLLVMOptions.indexBitwidth =
5657
DataLayout(module).getTypeSizeInBits(IndexType::get(module.getContext()));
5758
passManager.addPass(createConvertFuncToLLVMPass(funcToLLVMOptions));
59+
passManager.addPass(createArithToLLVMConversionPass());
5860
passManager.addPass(createReconcileUnrealizedCastsPass());
5961
passManager.addPass(createConvertVulkanLaunchFuncToVulkanCallsPass());
6062

0 commit comments

Comments
 (0)