Skip to content

Commit d753c43

Browse files
dcaballeIcohedron
authored andcommitted
[mlir][Vector] Add UB conversions to different tests and pipelines (llvm#125145)
This PR adds the UB to LLVM/SPIR-V conversion pass to some pipelines and tests. This is in preparation to introducing the generation of `ub.poison` in Vector dialect transformations (first one in llvm#125613). It should effectively be NFC at this point.
1 parent c7fed3b commit d753c43

File tree

9 files changed

+22
-27
lines changed

9 files changed

+22
-27
lines changed

mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
#ifndef MLIR_DIALECT_SPARSETENSOR_TRANSFORMS_PASSES_H_
1414
#define MLIR_DIALECT_SPARSETENSOR_TRANSFORMS_PASSES_H_
1515

16+
#include "mlir/Dialect/Bufferization/Transforms/OneShotAnalysis.h"
1617
#include "mlir/IR/PatternMatch.h"
1718
#include "mlir/Pass/Pass.h"
1819
#include "mlir/Transforms/DialectConversion.h"
19-
#include "mlir/Transforms/OneToNTypeConversion.h"
2020

2121
//===----------------------------------------------------------------------===//
2222
// Include the generated pass header (which needs some early definitions).

mlir/lib/Dialect/SparseTensor/Pipelines/SparseTensorPipelines.cpp

+4-9
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,15 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include "mlir/Dialect/SparseTensor/Pipelines/Passes.h"
10-
11-
#include "mlir/Conversion/ArithToLLVM/ArithToLLVM.h"
12-
#include "mlir/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.h"
13-
#include "mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h"
149
#include "mlir/Conversion/Passes.h"
1510
#include "mlir/Dialect/Arith/Transforms/Passes.h"
16-
#include "mlir/Dialect/Bufferization/Transforms/Bufferize.h"
17-
#include "mlir/Dialect/Bufferization/Transforms/OneShotAnalysis.h"
1811
#include "mlir/Dialect/Bufferization/Transforms/Passes.h"
1912
#include "mlir/Dialect/Func/IR/FuncOps.h"
2013
#include "mlir/Dialect/GPU/IR/GPUDialect.h"
2114
#include "mlir/Dialect/GPU/Transforms/Passes.h"
22-
#include "mlir/Dialect/LLVMIR/NVVMDialect.h"
2315
#include "mlir/Dialect/Linalg/Passes.h"
2416
#include "mlir/Dialect/MemRef/Transforms/Passes.h"
25-
#include "mlir/Dialect/SparseTensor/IR/SparseTensor.h"
17+
#include "mlir/Dialect/SparseTensor/Pipelines/Passes.h"
2618
#include "mlir/Dialect/SparseTensor/Transforms/Passes.h"
2719
#include "mlir/Pass/PassManager.h"
2820
#include "mlir/Transforms/Passes.h"
@@ -107,6 +99,9 @@ void mlir::sparse_tensor::buildSparsifier(OpPassManager &pm,
10799
pm.addPass(createGpuModuleToBinaryPass(gpuModuleToBinaryPassOptions));
108100
}
109101

102+
// Convert poison values.
103+
pm.addPass(createUBToLLVMConversionPass());
104+
110105
// Ensure all casts are realized.
111106
pm.addPass(createReconcileUnrealizedCastsPass());
112107
}

mlir/test/Integration/Dialect/Vector/CPU/shuffle16x16.mlir

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// RUN: mlir-opt %s -convert-vector-to-scf -convert-scf-to-cf \
22
// RUN: -transform-interpreter \
33
// RUN: -test-transform-dialect-erase-schedule \
4-
// RUN: -convert-vector-to-llvm -convert-func-to-llvm -convert-arith-to-llvm -convert-cf-to-llvm -reconcile-unrealized-casts | \
4+
// RUN: -convert-vector-to-llvm -convert-func-to-llvm \
5+
// RUN: -convert-arith-to-llvm -convert-cf-to-llvm \
6+
// RUN: -convert-ub-to-llvm -reconcile-unrealized-casts | \
57
// RUN: mlir-runner -e entry -entry-point-result=void \
68
// RUN: -shared-libs=%mlir_c_runner_utils | \
79
// RUN: FileCheck %s

mlir/test/Integration/Dialect/Vector/CPU/transfer-read-1d.mlir

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// RUN: mlir-opt %s -pass-pipeline="builtin.module(func.func(convert-vector-to-scf,expand-strided-metadata,lower-affine,convert-arith-to-llvm,convert-scf-to-cf),convert-vector-to-llvm,finalize-memref-to-llvm,convert-func-to-llvm,convert-arith-to-llvm,convert-cf-to-llvm,reconcile-unrealized-casts)" | \
1+
// RUN: mlir-opt %s -pass-pipeline="builtin.module(func.func(convert-vector-to-scf,expand-strided-metadata,lower-affine,convert-arith-to-llvm,convert-scf-to-cf),convert-vector-to-llvm,finalize-memref-to-llvm,convert-func-to-llvm,convert-arith-to-llvm,convert-ub-to-llvm,convert-cf-to-llvm,reconcile-unrealized-casts)" | \
22
// RUN: mlir-runner -e entry -entry-point-result=void \
33
// RUN: -shared-libs=%mlir_c_runner_utils | \
44
// RUN: FileCheck %s
55

6-
// RUN: mlir-opt %s -pass-pipeline="builtin.module(func.func(convert-vector-to-scf{full-unroll=true},expand-strided-metadata,lower-affine,convert-arith-to-llvm,convert-scf-to-cf),convert-vector-to-llvm,finalize-memref-to-llvm,convert-func-to-llvm,convert-arith-to-llvm,convert-cf-to-llvm,reconcile-unrealized-casts)" | \
6+
// RUN: mlir-opt %s -pass-pipeline="builtin.module(func.func(convert-vector-to-scf{full-unroll=true},expand-strided-metadata,lower-affine,convert-arith-to-llvm,convert-scf-to-cf),convert-vector-to-llvm,finalize-memref-to-llvm,convert-func-to-llvm,convert-arith-to-llvm,convert-ub-to-llvm,convert-cf-to-llvm,reconcile-unrealized-casts)" | \
77
// RUN: mlir-runner -e entry -entry-point-result=void \
88
// RUN: -shared-libs=%mlir_c_runner_utils | \
99
// RUN: FileCheck %s

mlir/test/Integration/Dialect/Vector/CPU/transfer-read-2d.mlir

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// RUN: mlir-opt %s -pass-pipeline="builtin.module(func.func(convert-vector-to-scf,lower-affine,convert-scf-to-cf),convert-vector-to-llvm,finalize-memref-to-llvm,convert-func-to-llvm,convert-arith-to-llvm,convert-cf-to-llvm,reconcile-unrealized-casts)" | \
1+
// RUN: mlir-opt %s -pass-pipeline="builtin.module(func.func(convert-vector-to-scf,lower-affine,convert-scf-to-cf),convert-vector-to-llvm,finalize-memref-to-llvm,convert-func-to-llvm,convert-arith-to-llvm,convert-cf-to-llvm,convert-ub-to-llvm,reconcile-unrealized-casts)" | \
22
// RUN: mlir-runner -e entry -entry-point-result=void \
33
// RUN: -shared-libs=%mlir_c_runner_utils | \
44
// RUN: FileCheck %s
55

6-
// RUN: mlir-opt %s -pass-pipeline="builtin.module(func.func(convert-vector-to-scf{full-unroll=true},lower-affine,convert-scf-to-cf),convert-vector-to-llvm,finalize-memref-to-llvm,convert-func-to-llvm,convert-arith-to-llvm,convert-cf-to-llvm,reconcile-unrealized-casts)" | \
6+
// RUN: mlir-opt %s -pass-pipeline="builtin.module(func.func(convert-vector-to-scf{full-unroll=true},lower-affine,convert-scf-to-cf),convert-vector-to-llvm,finalize-memref-to-llvm,convert-func-to-llvm,convert-arith-to-llvm,convert-cf-to-llvm,convert-ub-to-llvm,reconcile-unrealized-casts)" | \
77
// RUN: mlir-runner -e entry -entry-point-result=void \
88
// RUN: -shared-libs=%mlir_c_runner_utils | \
99
// RUN: FileCheck %s

mlir/test/Integration/Dialect/Vector/CPU/transfer-read-3d.mlir

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// RUN: mlir-opt %s -pass-pipeline="builtin.module(func.func(convert-vector-to-scf,lower-affine,convert-scf-to-cf),convert-vector-to-llvm,finalize-memref-to-llvm,convert-func-to-llvm,convert-arith-to-llvm,convert-cf-to-llvm,reconcile-unrealized-casts)" | \
1+
// RUN: mlir-opt %s -pass-pipeline="builtin.module(func.func(convert-vector-to-scf,lower-affine,convert-scf-to-cf),convert-vector-to-llvm,finalize-memref-to-llvm,convert-func-to-llvm,convert-arith-to-llvm,convert-cf-to-llvm,convert-ub-to-llvm,reconcile-unrealized-casts)" | \
22
// RUN: mlir-runner -e entry -entry-point-result=void \
33
// RUN: -shared-libs=%mlir_c_runner_utils | \
44
// RUN: FileCheck %s
55

6-
// RUN: mlir-opt %s -pass-pipeline="builtin.module(func.func(convert-vector-to-scf{full-unroll=true},lower-affine,convert-scf-to-cf),convert-vector-to-llvm,finalize-memref-to-llvm,convert-func-to-llvm,convert-arith-to-llvm,convert-cf-to-llvm,reconcile-unrealized-casts)" | \
6+
// RUN: mlir-opt %s -pass-pipeline="builtin.module(func.func(convert-vector-to-scf{full-unroll=true},lower-affine,convert-scf-to-cf),convert-vector-to-llvm,finalize-memref-to-llvm,convert-func-to-llvm,convert-arith-to-llvm,convert-cf-to-llvm,convert-ub-to-llvm,reconcile-unrealized-casts)" | \
77
// RUN: mlir-runner -e entry -entry-point-result=void \
88
// RUN: -shared-libs=%mlir_c_runner_utils | \
99
// RUN: FileCheck %s

mlir/test/Integration/Dialect/Vector/CPU/transfer-to-loops.mlir

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// RUN: mlir-opt %s -pass-pipeline="builtin.module(func.func(convert-vector-to-scf,lower-affine,convert-scf-to-cf),convert-vector-to-llvm,finalize-memref-to-llvm,convert-func-to-llvm,convert-arith-to-llvm,convert-cf-to-llvm,reconcile-unrealized-casts)" | \
1+
// RUN: mlir-opt %s -pass-pipeline="builtin.module(func.func(convert-vector-to-scf,lower-affine,convert-scf-to-cf),convert-vector-to-llvm,finalize-memref-to-llvm,convert-func-to-llvm,convert-arith-to-llvm,convert-cf-to-llvm,convert-ub-to-llvm,reconcile-unrealized-casts)" | \
22
// RUN: mlir-runner -e main -entry-point-result=void \
33
// RUN: -shared-libs=%mlir_runner_utils,%mlir_c_runner_utils | \
44
// RUN: FileCheck %s
55

6-
// RUN: mlir-opt %s -pass-pipeline="builtin.module(func.func(convert-vector-to-scf{full-unroll=true},lower-affine,convert-scf-to-cf),convert-vector-to-llvm,finalize-memref-to-llvm,convert-func-to-llvm,convert-arith-to-llvm,convert-cf-to-llvm,reconcile-unrealized-casts)" | \
6+
// RUN: mlir-opt %s -pass-pipeline="builtin.module(func.func(convert-vector-to-scf{full-unroll=true},lower-affine,convert-scf-to-cf),convert-vector-to-llvm,finalize-memref-to-llvm,convert-func-to-llvm,convert-arith-to-llvm,convert-cf-to-llvm,convert-ub-to-llvm,reconcile-unrealized-casts)" | \
77
// RUN: mlir-runner -e main -entry-point-result=void \
88
// RUN: -shared-libs=%mlir_runner_utils,%mlir_c_runner_utils | \
99
// RUN: FileCheck %s

mlir/test/lib/Conversion/ConvertToSPIRV/TestSPIRVVectorUnrolling.cpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,12 @@
66
//
77
//===-------------------------------------------------------------------===//
88

9-
#include "mlir/Dialect/Arith/IR/Arith.h"
10-
#include "mlir/Dialect/Func/IR/FuncOps.h"
119
#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
1210
#include "mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h"
11+
#include "mlir/Dialect/UB/IR/UBOps.h"
1312
#include "mlir/Dialect/Vector/IR/VectorOps.h"
14-
#include "mlir/Dialect/Vector/Transforms/LoweringPatterns.h"
1513
#include "mlir/Pass/Pass.h"
1614
#include "mlir/Pass/PassManager.h"
17-
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
1815

1916
namespace mlir {
2017
namespace {
@@ -30,7 +27,8 @@ struct TestSPIRVVectorUnrolling final
3027
}
3128

3229
void getDependentDialects(DialectRegistry &registry) const override {
33-
registry.insert<spirv::SPIRVDialect, vector::VectorDialect>();
30+
registry
31+
.insert<spirv::SPIRVDialect, vector::VectorDialect, ub::UBDialect>();
3432
}
3533

3634
void runOnOperation() override {

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,12 @@
2020
#include "mlir/Conversion/MemRefToLLVM/MemRefToLLVM.h"
2121
#include "mlir/Conversion/ReconcileUnrealizedCasts/ReconcileUnrealizedCasts.h"
2222
#include "mlir/Conversion/SCFToControlFlow/SCFToControlFlow.h"
23+
#include "mlir/Conversion/UBToLLVM/UBToLLVM.h"
2324
#include "mlir/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.h"
2425
#include "mlir/Conversion/VectorToSCF/VectorToSCF.h"
2526
#include "mlir/Dialect/Func/IR/FuncOps.h"
26-
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
2727
#include "mlir/Dialect/Linalg/Passes.h"
2828
#include "mlir/Dialect/MemRef/Transforms/Passes.h"
29-
#include "mlir/IR/DialectRegistry.h"
30-
#include "mlir/Pass/Pass.h"
3129
#include "mlir/Pass/PassManager.h"
3230
#include "mlir/Pass/PassOptions.h"
3331
#include "mlir/Transforms/Passes.h"
@@ -81,6 +79,8 @@ void buildTestLowerToLLVM(OpPassManager &pm,
8179
pm.addPass(createConvertControlFlowToLLVMPass());
8280
// Convert Index to LLVM (always needed).
8381
pm.addPass(createConvertIndexToLLVMPass());
82+
// Convert UB to LLVM (always needed).
83+
pm.addPass(createUBToLLVMConversionPass());
8484
// Convert remaining unrealized_casts (always needed).
8585
pm.addPass(createReconcileUnrealizedCastsPass());
8686
}

0 commit comments

Comments
 (0)