Skip to content

Commit e4c683f

Browse files
authored
Integrate LLVM at 73f11ac (#19941)
We had previously cherry-picked llvm/llvm-project@73f11ac in #19939. Now we're integrating up to that commit, so it's no longer a cherry-pick. Reverting llvm/llvm-project#125789 because it breaks TorchToTosa, in torch-mlir. We will need to wait for this to be resolved in torch-mlir, then simultaneously bump torch-mlir and drop the revert. Chery-pick a Bazel fix: llvm/llvm-project@4df287a --------- Signed-off-by: Benoit Jacob <[email protected]>
1 parent 0781072 commit e4c683f

File tree

14 files changed

+35
-17
lines changed

14 files changed

+35
-17
lines changed

compiler/src/iree/compiler/Codegen/LLVMCPU/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ iree_compiler_cc_library(
164164
"@llvm-project//mlir:TransformDialect",
165165
"@llvm-project//mlir:TransformUtils",
166166
"@llvm-project//mlir:Transforms",
167+
"@llvm-project//mlir:UBDialect",
168+
"@llvm-project//mlir:UBToLLVM",
167169
"@llvm-project//mlir:ValueBoundsOpInterface",
168170
"@llvm-project//mlir:VectorDialect",
169171
"@llvm-project//mlir:VectorToArmSME",

compiler/src/iree/compiler/Codegen/LLVMCPU/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ iree_cc_library(
138138
MLIRTransformDialect
139139
MLIRTransformUtils
140140
MLIRTransforms
141+
MLIRUBDialect
142+
MLIRUBToLLVM
141143
MLIRValueBoundsOpInterface
142144
MLIRVectorDialect
143145
MLIRVectorToArmSME

compiler/src/iree/compiler/Codegen/LLVMCPU/ConvertToLLVM.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "mlir/Conversion/ReconcileUnrealizedCasts/ReconcileUnrealizedCasts.h"
3838
#include "mlir/Conversion/SCFToControlFlow/SCFToControlFlow.h"
3939
#include "mlir/Conversion/TosaToArith/TosaToArith.h"
40+
#include "mlir/Conversion/UBToLLVM/UBToLLVM.h"
4041
#include "mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h"
4142
#include "mlir/Conversion/VectorToSCF/VectorToSCF.h"
4243
#include "mlir/Dialect/Arith/IR/Arith.h"
@@ -1058,9 +1059,9 @@ void ConvertToLLVMPass::runOnOperation() {
10581059
vector::populateVectorStepLoweringPatterns(patterns);
10591060
populateVectorToLLVMConversionPatterns(typeConverter, patterns,
10601061
reassociateFpReductions);
1062+
ub::populateUBToLLVMConversionPatterns(typeConverter, patterns);
10611063
vector::populateVectorTransferLoweringPatterns(patterns,
10621064
/*maxTransferRank=*/1);
1063-
10641065
if (isAArch64(targetAttr) &&
10651066
(hasAnySVEFeature(targetAttr) || hasSMEFeature(targetAttr))) {
10661067
populateArmSVELegalizeForLLVMExportPatterns(typeConverter, patterns);

compiler/src/iree/compiler/Codegen/LLVMGPU/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ iree_compiler_cc_library(
215215
"@llvm-project//mlir:TransformDialect",
216216
"@llvm-project//mlir:TransformUtils",
217217
"@llvm-project//mlir:Transforms",
218+
"@llvm-project//mlir:UBDialect",
219+
"@llvm-project//mlir:UBToLLVM",
218220
"@llvm-project//mlir:ValueBoundsOpInterface",
219221
"@llvm-project//mlir:VectorDialect",
220222
"@llvm-project//mlir:VectorToGPU",

compiler/src/iree/compiler/Codegen/LLVMGPU/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ iree_cc_library(
163163
MLIRTransformDialect
164164
MLIRTransformUtils
165165
MLIRTransforms
166+
MLIRUBDialect
167+
MLIRUBToLLVM
166168
MLIRValueBoundsOpInterface
167169
MLIRVectorDialect
168170
MLIRVectorToGPU

compiler/src/iree/compiler/Codegen/LLVMGPU/ConvertToNVVM.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@
2222
#include "mlir/Conversion/MemRefToLLVM/MemRefToLLVM.h"
2323
#include "mlir/Conversion/NVGPUToNVVM/NVGPUToNVVM.h"
2424
#include "mlir/Conversion/NVVMToLLVM/NVVMToLLVM.h"
25+
#include "mlir/Conversion/UBToLLVM/UBToLLVM.h"
2526
#include "mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h"
2627
#include "mlir/Dialect/Affine/IR/AffineOps.h"
2728
#include "mlir/Dialect/Arith/Transforms/Passes.h"
2829
#include "mlir/Dialect/GPU/Transforms/Passes.h"
2930
#include "mlir/Dialect/LLVMIR/NVVMDialect.h"
3031
#include "mlir/Dialect/MemRef/Transforms/Transforms.h"
3132
#include "mlir/Dialect/NVGPU/IR/NVGPUDialect.h"
33+
#include "mlir/Dialect/UB/IR/UBOps.h"
3234
#include "mlir/Dialect/Vector/IR/VectorOps.h"
3335
#include "mlir/Dialect/Vector/Transforms/LoweringPatterns.h"
3436
#include "mlir/Dialect/Vector/Transforms/VectorRewritePatterns.h"
@@ -53,7 +55,7 @@ struct ConvertToNVVMPass final
5355
void getDependentDialects(DialectRegistry &registry) const override {
5456
registry
5557
.insert<gpu::GPUDialect, IREE::GPU::IREEGPUDialect, LLVM::LLVMDialect,
56-
NVVM::NVVMDialect, affine::AffineDialect>();
58+
NVVM::NVVMDialect, affine::AffineDialect, ub::UBDialect>();
5759
}
5860
void runOnOperation() override {
5961
ModuleOp m = getOperation();
@@ -161,6 +163,7 @@ struct ConvertToNVVMPass final
161163
populateGpuToNVVMConversionPatterns(converter, llvmPatterns);
162164
populateNVGPUToNVVMConversionPatterns(converter, llvmPatterns);
163165
populateGpuWMMAToNVVMConversionPatterns(converter, llvmPatterns);
166+
ub::populateUBToLLVMConversionPatterns(converter, llvmPatterns);
164167

165168
/// Target specification.
166169
LLVMConversionTarget target(getContext());

compiler/src/iree/compiler/Codegen/LLVMGPU/ConvertToROCDL.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@
2222
#include "mlir/Conversion/LLVMCommon/TypeConverter.h"
2323
#include "mlir/Conversion/MathToLLVM/MathToLLVM.h"
2424
#include "mlir/Conversion/MemRefToLLVM/MemRefToLLVM.h"
25+
#include "mlir/Conversion/UBToLLVM/UBToLLVM.h"
2526
#include "mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h"
2627
#include "mlir/Dialect/AMDGPU/IR/AMDGPUDialect.h"
2728
#include "mlir/Dialect/Arith/Transforms/Passes.h"
2829
#include "mlir/Dialect/GPU/IR/GPUDialect.h"
2930
#include "mlir/Dialect/GPU/Transforms/Passes.h"
3031
#include "mlir/Dialect/LLVMIR/ROCDLDialect.h"
3132
#include "mlir/Dialect/MemRef/Transforms/Transforms.h"
33+
#include "mlir/Dialect/UB/IR/UBOps.h"
3234
#include "mlir/Dialect/Vector/IR/VectorOps.h"
3335
#include "mlir/Dialect/Vector/Transforms/LoweringPatterns.h"
3436
#include "mlir/Dialect/Vector/Transforms/VectorRewritePatterns.h"
@@ -99,9 +101,9 @@ struct ConvertToROCDLPass final
99101
ConvertToROCDLPass>::ConvertToROCDLPassBase;
100102

101103
void getDependentDialects(DialectRegistry &registry) const override {
102-
registry
103-
.insert<IREE::GPU::IREEGPUDialect, LLVM::LLVMDialect,
104-
ROCDL::ROCDLDialect, amdgpu::AMDGPUDialect, gpu::GPUDialect>();
104+
registry.insert<IREE::GPU::IREEGPUDialect, LLVM::LLVMDialect,
105+
ROCDL::ROCDLDialect, amdgpu::AMDGPUDialect, gpu::GPUDialect,
106+
ub::UBDialect>();
105107
}
106108
void runOnOperation() override {
107109
ModuleOp m = getOperation();
@@ -238,6 +240,8 @@ struct ConvertToROCDLPass final
238240
LLVMConversionTarget target(getContext());
239241
populateFuncToLLVMFuncOpConversionPattern(converter, llvmPatterns);
240242
configureGpuToROCDLConversionLegality(target);
243+
ub::populateUBToLLVMConversionPatterns(converter, llvmPatterns);
244+
241245
if (failed(applyPartialConversion(m, target, std::move(llvmPatterns))))
242246
signalPassFailure();
243247
}

compiler/src/iree/compiler/Codegen/LLVMGPU/test/vector_lowering.mlir

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: iree-opt --pass-pipeline="builtin.module(func.func(iree-llvmgpu-vector-lowering))" --split-input-file %s | FileCheck %s
1+
// RUN: iree-opt --pass-pipeline="builtin.module(func.func(iree-llvmgpu-vector-lowering,canonicalize,cse))" --split-input-file %s | FileCheck %s
22

33
module {
44
func.func @broadcast_read_lowering(%arg0: memref<4096x32xf16>) -> vector<1x8xf16> {
@@ -11,9 +11,8 @@ module {
1111
}
1212
// CHECK-LABEL: func.func @broadcast_read_lowering
1313
// CHECK-SAME: (%[[ARG0:.+]]: memref<4096x32xf16>)
14-
// CHECK: %[[INIT:.+]] = arith.constant dense<0.000000e+00> : vector<1x8xf16>
1514
// CHECK: %[[LOAD:.+]] = vector.load %[[ARG0]]{{.*}} : memref<4096x32xf16>
1615
// CHECK: %[[ELEM:.+]] = vector.extract %[[LOAD]][0] : f16 from vector<1xf16>
1716
// CHECK: %[[SPLAT:.+]] = vector.splat %[[ELEM]] : vector<8xf16>
18-
// CHECK: %[[INSERT:.+]] = vector.insert %[[SPLAT]], %[[INIT]] [0] : vector<8xf16> into vector<1x8xf16>
17+
// CHECK: %[[INSERT:.+]] = vector.broadcast %[[SPLAT]] : vector<8xf16> to vector<1x8xf16>
1918
// CHECK: return %[[INSERT]]

compiler/src/iree/compiler/Codegen/SPIRV/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ iree_compiler_cc_library(
154154
"@llvm-project//mlir:TransformDialect",
155155
"@llvm-project//mlir:TransformUtils",
156156
"@llvm-project//mlir:Transforms",
157+
"@llvm-project//mlir:UBToSPIRV",
157158
"@llvm-project//mlir:VectorDialect",
158159
"@llvm-project//mlir:VectorInterfaces",
159160
"@llvm-project//mlir:VectorToGPU",

compiler/src/iree/compiler/Codegen/SPIRV/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ iree_cc_library(
129129
MLIRTransformDialect
130130
MLIRTransformUtils
131131
MLIRTransforms
132+
MLIRUBToSPIRV
132133
MLIRVectorDialect
133134
MLIRVectorInterfaces
134135
MLIRVectorToGPU

0 commit comments

Comments
 (0)