[Mlir-commits] [mlir] Revert "[mlir][spirv] Add a generic `convert-to-spirv` pass" (PR #96332)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Jun 21 09:56:59 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-spirv

@llvm/pr-subscribers-mlir

Author: Angel Zhang (angelz913)

<details>
<summary>Changes</summary>

Reverts llvm/llvm-project#<!-- -->95942 due to link failures.

---

Patch is 38.80 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/96332.diff


13 Files Affected:

- (removed) mlir/include/mlir/Conversion/ConvertToSPIRV/ConvertToSPIRVPass.h (-22) 
- (modified) mlir/include/mlir/Conversion/Passes.h (-1) 
- (modified) mlir/include/mlir/Conversion/Passes.td (-12) 
- (modified) mlir/lib/Conversion/CMakeLists.txt (-1) 
- (removed) mlir/lib/Conversion/ConvertToSPIRV/CMakeLists.txt (-22) 
- (removed) mlir/lib/Conversion/ConvertToSPIRV/ConvertToSPIRVPass.cpp (-71) 
- (removed) mlir/test/Conversion/ConvertToSPIRV/arith.mlir (-218) 
- (removed) mlir/test/Conversion/ConvertToSPIRV/combined.mlir (-47) 
- (removed) mlir/test/Conversion/ConvertToSPIRV/index.mlir (-63) 
- (removed) mlir/test/Conversion/ConvertToSPIRV/scf.mlir (-47) 
- (removed) mlir/test/Conversion/ConvertToSPIRV/simple.mlir (-15) 
- (removed) mlir/test/Conversion/ConvertToSPIRV/ub.mlir (-9) 
- (removed) mlir/test/Conversion/ConvertToSPIRV/vector.mlir (-439) 


``````````diff
diff --git a/mlir/include/mlir/Conversion/ConvertToSPIRV/ConvertToSPIRVPass.h b/mlir/include/mlir/Conversion/ConvertToSPIRV/ConvertToSPIRVPass.h
deleted file mode 100644
index 3852782247527..0000000000000
--- a/mlir/include/mlir/Conversion/ConvertToSPIRV/ConvertToSPIRVPass.h
+++ /dev/null
@@ -1,22 +0,0 @@
-//===- ConvertToSPIRVPass.h - Conversion to SPIR-V pass ---*- C++ -*-=========//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef MLIR_CONVERSION_CONVERTTOSPIRV_CONVERTTOSPIRVPASS_H
-#define MLIR_CONVERSION_CONVERTTOSPIRV_CONVERTTOSPIRVPASS_H
-
-#include <memory>
-
-namespace mlir {
-class Pass;
-
-#define GEN_PASS_DECL_CONVERTTOSPIRVPASS
-#include "mlir/Conversion/Passes.h.inc"
-
-} // namespace mlir
-
-#endif // MLIR_CONVERSION_CONVERTTOSPIRV_CONVERTTOSPIRVPASS_H
diff --git a/mlir/include/mlir/Conversion/Passes.h b/mlir/include/mlir/Conversion/Passes.h
index 8c6f85d461aea..7700299b3a4f3 100644
--- a/mlir/include/mlir/Conversion/Passes.h
+++ b/mlir/include/mlir/Conversion/Passes.h
@@ -30,7 +30,6 @@
 #include "mlir/Conversion/ControlFlowToSPIRV/ControlFlowToSPIRV.h"
 #include "mlir/Conversion/ControlFlowToSPIRV/ControlFlowToSPIRVPass.h"
 #include "mlir/Conversion/ConvertToLLVM/ToLLVMPass.h"
-#include "mlir/Conversion/ConvertToSPIRV/ConvertToSPIRVPass.h"
 #include "mlir/Conversion/FuncToEmitC/FuncToEmitCPass.h"
 #include "mlir/Conversion/FuncToLLVM/ConvertFuncToLLVMPass.h"
 #include "mlir/Conversion/FuncToSPIRV/FuncToSPIRVPass.h"
diff --git a/mlir/include/mlir/Conversion/Passes.td b/mlir/include/mlir/Conversion/Passes.td
index 560b088dbe5cd..2315686839c20 100644
--- a/mlir/include/mlir/Conversion/Passes.td
+++ b/mlir/include/mlir/Conversion/Passes.td
@@ -31,18 +31,6 @@ def ConvertToLLVMPass : Pass<"convert-to-llvm"> {
   ];
 }
 
-//===----------------------------------------------------------------------===//
-// ToSPIRV
-//===----------------------------------------------------------------------===//
-
-def ConvertToSPIRVPass : Pass<"convert-to-spirv"> {
-  let summary = "Convert to SPIR-V";
-  let description = [{
-    This is a generic pass to convert to SPIR-V.
-  }];
-  let dependentDialects = ["spirv::SPIRVDialect"];
-}
-
 //===----------------------------------------------------------------------===//
 // AffineToStandard
 //===----------------------------------------------------------------------===//
diff --git a/mlir/lib/Conversion/CMakeLists.txt b/mlir/lib/Conversion/CMakeLists.txt
index e107738a4c50c..0a03a2e133db1 100644
--- a/mlir/lib/Conversion/CMakeLists.txt
+++ b/mlir/lib/Conversion/CMakeLists.txt
@@ -19,7 +19,6 @@ add_subdirectory(ControlFlowToLLVM)
 add_subdirectory(ControlFlowToSCF)
 add_subdirectory(ControlFlowToSPIRV)
 add_subdirectory(ConvertToLLVM)
-add_subdirectory(ConvertToSPIRV)
 add_subdirectory(FuncToEmitC)
 add_subdirectory(FuncToLLVM)
 add_subdirectory(FuncToSPIRV)
diff --git a/mlir/lib/Conversion/ConvertToSPIRV/CMakeLists.txt b/mlir/lib/Conversion/ConvertToSPIRV/CMakeLists.txt
deleted file mode 100644
index 9a93301f09b48..0000000000000
--- a/mlir/lib/Conversion/ConvertToSPIRV/CMakeLists.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-set(LLVM_OPTIONAL_SOURCES
-  ConvertToSPIRVPass.cpp
-)
-
-add_mlir_conversion_library(MLIRConvertToSPIRVPass
-  ConvertToSPIRVPass.cpp
-
-  ADDITIONAL_HEADER_DIRS
-  ${MLIR_MAIN_INCLUDE_DIR}/mlir/Conversion/ConvertToSPIRV
-
-  DEPENDS
-  MLIRConversionPassIncGen
-
-  LINK_LIBS PUBLIC
-  MLIRIR
-  MLIRPass
-  MLIRRewrite
-  MLIRSPIRVConversion
-  MLIRSPIRVDialect
-  MLIRSupport
-  MLIRTransformUtils
-  )
diff --git a/mlir/lib/Conversion/ConvertToSPIRV/ConvertToSPIRVPass.cpp b/mlir/lib/Conversion/ConvertToSPIRV/ConvertToSPIRVPass.cpp
deleted file mode 100644
index b5be4654bcb25..0000000000000
--- a/mlir/lib/Conversion/ConvertToSPIRV/ConvertToSPIRVPass.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-//===- ConvertToSPIRVPass.cpp - MLIR SPIR-V Conversion --------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "mlir/Conversion/ConvertToSPIRV/ConvertToSPIRVPass.h"
-#include "mlir/Conversion/ArithToSPIRV/ArithToSPIRV.h"
-#include "mlir/Conversion/FuncToSPIRV/FuncToSPIRV.h"
-#include "mlir/Conversion/IndexToSPIRV/IndexToSPIRV.h"
-#include "mlir/Conversion/SCFToSPIRV/SCFToSPIRV.h"
-#include "mlir/Conversion/UBToSPIRV/UBToSPIRV.h"
-#include "mlir/Conversion/VectorToSPIRV/VectorToSPIRV.h"
-#include "mlir/Dialect/Arith/Transforms/Passes.h"
-#include "mlir/Dialect/SPIRV/IR/SPIRVAttributes.h"
-#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
-#include "mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h"
-#include "mlir/Dialect/Vector/Transforms/VectorRewritePatterns.h"
-#include "mlir/IR/PatternMatch.h"
-#include "mlir/Pass/Pass.h"
-#include "mlir/Rewrite/FrozenRewritePatternSet.h"
-#include "mlir/Transforms/DialectConversion.h"
-#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
-#include <memory>
-
-#define DEBUG_TYPE "convert-to-spirv"
-
-namespace mlir {
-#define GEN_PASS_DEF_CONVERTTOSPIRVPASS
-#include "mlir/Conversion/Passes.h.inc"
-} // namespace mlir
-
-using namespace mlir;
-
-namespace {
-
-/// A pass to perform the SPIR-V conversion.
-struct ConvertToSPIRVPass final
-    : impl::ConvertToSPIRVPassBase<ConvertToSPIRVPass> {
-
-  void runOnOperation() override {
-    MLIRContext *context = &getContext();
-    Operation *op = getOperation();
-
-    spirv::TargetEnvAttr targetAttr = spirv::lookupTargetEnvOrDefault(op);
-    SPIRVTypeConverter typeConverter(targetAttr);
-
-    RewritePatternSet patterns(context);
-    ScfToSPIRVContext scfToSPIRVContext;
-
-    // Populate patterns.
-    arith::populateCeilFloorDivExpandOpsPatterns(patterns);
-    arith::populateArithToSPIRVPatterns(typeConverter, patterns);
-    populateBuiltinFuncToSPIRVPatterns(typeConverter, patterns);
-    populateFuncToSPIRVPatterns(typeConverter, patterns);
-    index::populateIndexToSPIRVPatterns(typeConverter, patterns);
-    populateVectorToSPIRVPatterns(typeConverter, patterns);
-    populateSCFToSPIRVPatterns(typeConverter, scfToSPIRVContext, patterns);
-    ub::populateUBToSPIRVConversionPatterns(typeConverter, patterns);
-
-    std::unique_ptr<ConversionTarget> target =
-        SPIRVConversionTarget::get(targetAttr);
-
-    if (failed(applyPartialConversion(op, *target, std::move(patterns))))
-      return signalPassFailure();
-  }
-};
-
-} // namespace
diff --git a/mlir/test/Conversion/ConvertToSPIRV/arith.mlir b/mlir/test/Conversion/ConvertToSPIRV/arith.mlir
deleted file mode 100644
index a2adc0ad9c7a5..0000000000000
--- a/mlir/test/Conversion/ConvertToSPIRV/arith.mlir
+++ /dev/null
@@ -1,218 +0,0 @@
-// RUN: mlir-opt -convert-to-spirv -split-input-file %s | FileCheck %s
-
-//===----------------------------------------------------------------------===//
-// arithmetic ops
-//===----------------------------------------------------------------------===//
-
-// CHECK-LABEL: @int32_scalar
-func.func @int32_scalar(%lhs: i32, %rhs: i32) {
-  // CHECK: spirv.IAdd %{{.*}}, %{{.*}}: i32
-  %0 = arith.addi %lhs, %rhs: i32
-  // CHECK: spirv.ISub %{{.*}}, %{{.*}}: i32
-  %1 = arith.subi %lhs, %rhs: i32
-  // CHECK: spirv.IMul %{{.*}}, %{{.*}}: i32
-  %2 = arith.muli %lhs, %rhs: i32
-  // CHECK: spirv.SDiv %{{.*}}, %{{.*}}: i32
-  %3 = arith.divsi %lhs, %rhs: i32
-  // CHECK: spirv.UDiv %{{.*}}, %{{.*}}: i32
-  %4 = arith.divui %lhs, %rhs: i32
-  // CHECK: spirv.UMod %{{.*}}, %{{.*}}: i32
-  %5 = arith.remui %lhs, %rhs: i32
-  return
-}
-
-// CHECK-LABEL: @int32_scalar_srem
-// CHECK-SAME: (%[[LHS:.+]]: i32, %[[RHS:.+]]: i32)
-func.func @int32_scalar_srem(%lhs: i32, %rhs: i32) {
-  // CHECK: %[[LABS:.+]] = spirv.GL.SAbs %[[LHS]] : i32
-  // CHECK: %[[RABS:.+]] = spirv.GL.SAbs %[[RHS]] : i32
-  // CHECK:  %[[ABS:.+]] = spirv.UMod %[[LABS]], %[[RABS]] : i32
-  // CHECK:  %[[POS:.+]] = spirv.IEqual %[[LHS]], %[[LABS]] : i32
-  // CHECK:  %[[NEG:.+]] = spirv.SNegate %[[ABS]] : i32
-  // CHECK:      %{{.+}} = spirv.Select %[[POS]], %[[ABS]], %[[NEG]] : i1, i32
-  %0 = arith.remsi %lhs, %rhs: i32
-  return
-}
-
-// -----
-
-//===----------------------------------------------------------------------===//
-// arith bit ops
-//===----------------------------------------------------------------------===//
-
-// CHECK-LABEL: @bitwise_scalar
-func.func @bitwise_scalar(%arg0 : i32, %arg1 : i32) {
-  // CHECK: spirv.BitwiseAnd
-  %0 = arith.andi %arg0, %arg1 : i32
-  // CHECK: spirv.BitwiseOr
-  %1 = arith.ori %arg0, %arg1 : i32
-  // CHECK: spirv.BitwiseXor
-  %2 = arith.xori %arg0, %arg1 : i32
-  return
-}
-
-// CHECK-LABEL: @bitwise_vector
-func.func @bitwise_vector(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) {
-  // CHECK: spirv.BitwiseAnd
-  %0 = arith.andi %arg0, %arg1 : vector<4xi32>
-  // CHECK: spirv.BitwiseOr
-  %1 = arith.ori %arg0, %arg1 : vector<4xi32>
-  // CHECK: spirv.BitwiseXor
-  %2 = arith.xori %arg0, %arg1 : vector<4xi32>
-  return
-}
-
-// CHECK-LABEL: @logical_scalar
-func.func @logical_scalar(%arg0 : i1, %arg1 : i1) {
-  // CHECK: spirv.LogicalAnd
-  %0 = arith.andi %arg0, %arg1 : i1
-  // CHECK: spirv.LogicalOr
-  %1 = arith.ori %arg0, %arg1 : i1
-  // CHECK: spirv.LogicalNotEqual
-  %2 = arith.xori %arg0, %arg1 : i1
-  return
-}
-
-// CHECK-LABEL: @logical_vector
-func.func @logical_vector(%arg0 : vector<4xi1>, %arg1 : vector<4xi1>) {
-  // CHECK: spirv.LogicalAnd
-  %0 = arith.andi %arg0, %arg1 : vector<4xi1>
-  // CHECK: spirv.LogicalOr
-  %1 = arith.ori %arg0, %arg1 : vector<4xi1>
-  // CHECK: spirv.LogicalNotEqual
-  %2 = arith.xori %arg0, %arg1 : vector<4xi1>
-  return
-}
-
-// CHECK-LABEL: @shift_scalar
-func.func @shift_scalar(%arg0 : i32, %arg1 : i32) {
-  // CHECK: spirv.ShiftLeftLogical
-  %0 = arith.shli %arg0, %arg1 : i32
-  // CHECK: spirv.ShiftRightArithmetic
-  %1 = arith.shrsi %arg0, %arg1 : i32
-  // CHECK: spirv.ShiftRightLogical
-  %2 = arith.shrui %arg0, %arg1 : i32
-  return
-}
-
-// CHECK-LABEL: @shift_vector
-func.func @shift_vector(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) {
-  // CHECK: spirv.ShiftLeftLogical
-  %0 = arith.shli %arg0, %arg1 : vector<4xi32>
-  // CHECK: spirv.ShiftRightArithmetic
-  %1 = arith.shrsi %arg0, %arg1 : vector<4xi32>
-  // CHECK: spirv.ShiftRightLogical
-  %2 = arith.shrui %arg0, %arg1 : vector<4xi32>
-  return
-}
-
-// -----
-
-//===----------------------------------------------------------------------===//
-// arith.cmpf
-//===----------------------------------------------------------------------===//
-
-// CHECK-LABEL: @cmpf
-func.func @cmpf(%arg0 : f32, %arg1 : f32) {
-  // CHECK: spirv.FOrdEqual
-  %1 = arith.cmpf oeq, %arg0, %arg1 : f32
-  return
-}
-
-// CHECK-LABEL: @vec1cmpf
-func.func @vec1cmpf(%arg0 : vector<1xf32>, %arg1 : vector<1xf32>) {
-  // CHECK: spirv.FOrdGreaterThan
-  %0 = arith.cmpf ogt, %arg0, %arg1 : vector<1xf32>
-  // CHECK: spirv.FUnordLessThan
-  %1 = arith.cmpf ult, %arg0, %arg1 : vector<1xf32>
-  return
-}
-
-// -----
-
-//===----------------------------------------------------------------------===//
-// arith.cmpi
-//===----------------------------------------------------------------------===//
-
-// CHECK-LABEL: @cmpi
-func.func @cmpi(%arg0 : i32, %arg1 : i32) {
-  // CHECK: spirv.IEqual
-  %0 = arith.cmpi eq, %arg0, %arg1 : i32
-  return
-}
-
-// CHECK-LABEL: @indexcmpi
-func.func @indexcmpi(%arg0 : index, %arg1 : index) {
-  // CHECK: spirv.IEqual
-  %0 = arith.cmpi eq, %arg0, %arg1 : index
-  return
-}
-
-// CHECK-LABEL: @vec1cmpi
-func.func @vec1cmpi(%arg0 : vector<1xi32>, %arg1 : vector<1xi32>) {
-  // CHECK: spirv.ULessThan
-  %0 = arith.cmpi ult, %arg0, %arg1 : vector<1xi32>
-  // CHECK: spirv.SGreaterThan
-  %1 = arith.cmpi sgt, %arg0, %arg1 : vector<1xi32>
-  return
-}
-
-// CHECK-LABEL: @boolcmpi_equality
-func.func @boolcmpi_equality(%arg0 : i1, %arg1 : i1) {
-  // CHECK: spirv.LogicalEqual
-  %0 = arith.cmpi eq, %arg0, %arg1 : i1
-  // CHECK: spirv.LogicalNotEqual
-  %1 = arith.cmpi ne, %arg0, %arg1 : i1
-  return
-}
-
-// CHECK-LABEL: @boolcmpi_unsigned
-func.func @boolcmpi_unsigned(%arg0 : i1, %arg1 : i1) {
-  // CHECK-COUNT-2: spirv.Select
-  // CHECK: spirv.UGreaterThanEqual
-  %0 = arith.cmpi uge, %arg0, %arg1 : i1
-  // CHECK-COUNT-2: spirv.Select
-  // CHECK: spirv.ULessThan
-  %1 = arith.cmpi ult, %arg0, %arg1 : i1
-  return
-}
-
-// CHECK-LABEL: @vec1boolcmpi_equality
-func.func @vec1boolcmpi_equality(%arg0 : vector<1xi1>, %arg1 : vector<1xi1>) {
-  // CHECK: spirv.LogicalEqual
-  %0 = arith.cmpi eq, %arg0, %arg1 : vector<1xi1>
-  // CHECK: spirv.LogicalNotEqual
-  %1 = arith.cmpi ne, %arg0, %arg1 : vector<1xi1>
-  return
-}
-
-// CHECK-LABEL: @vec1boolcmpi_unsigned
-func.func @vec1boolcmpi_unsigned(%arg0 : vector<1xi1>, %arg1 : vector<1xi1>) {
-  // CHECK-COUNT-2: spirv.Select
-  // CHECK: spirv.UGreaterThanEqual
-  %0 = arith.cmpi uge, %arg0, %arg1 : vector<1xi1>
-  // CHECK-COUNT-2: spirv.Select
-  // CHECK: spirv.ULessThan
-  %1 = arith.cmpi ult, %arg0, %arg1 : vector<1xi1>
-  return
-}
-
-// CHECK-LABEL: @vecboolcmpi_equality
-func.func @vecboolcmpi_equality(%arg0 : vector<4xi1>, %arg1 : vector<4xi1>) {
-  // CHECK: spirv.LogicalEqual
-  %0 = arith.cmpi eq, %arg0, %arg1 : vector<4xi1>
-  // CHECK: spirv.LogicalNotEqual
-  %1 = arith.cmpi ne, %arg0, %arg1 : vector<4xi1>
-  return
-}
-
-// CHECK-LABEL: @vecboolcmpi_unsigned
-func.func @vecboolcmpi_unsigned(%arg0 : vector<3xi1>, %arg1 : vector<3xi1>) {
-  // CHECK-COUNT-2: spirv.Select
-  // CHECK: spirv.UGreaterThanEqual
-  %0 = arith.cmpi uge, %arg0, %arg1 : vector<3xi1>
-  // CHECK-COUNT-2: spirv.Select
-  // CHECK: spirv.ULessThan
-  %1 = arith.cmpi ult, %arg0, %arg1 : vector<3xi1>
-  return
-}
diff --git a/mlir/test/Conversion/ConvertToSPIRV/combined.mlir b/mlir/test/Conversion/ConvertToSPIRV/combined.mlir
deleted file mode 100644
index 9e908465cb142..0000000000000
--- a/mlir/test/Conversion/ConvertToSPIRV/combined.mlir
+++ /dev/null
@@ -1,47 +0,0 @@
-// RUN: mlir-opt -convert-to-spirv %s | FileCheck %s
-
-// CHECK-LABEL: @combined
-// CHECK: %[[C0_F32:.*]] = spirv.Constant 0.000000e+00 : f32
-// CHECK: %[[C1_F32:.*]]  = spirv.Constant 1.000000e+00 : f32
-// CHECK: %[[C0_I32:.*]] = spirv.Constant 0 : i32
-// CHECK: %[[C4_I32:.*]] = spirv.Constant 4 : i32
-// CHECK: %[[C0_I32_0:.*]] = spirv.Constant 0 : i32
-// CHECK: %[[C4_I32_0:.*]] = spirv.Constant 4 : i32
-// CHECK: %[[C1_I32:.*]] = spirv.Constant 1 : i32
-// CHECK: %[[VEC:.*]] = spirv.Constant dense<1.000000e+00> : vector<4xf32>
-// CHECK: %[[VARIABLE:.*]] = spirv.Variable : !spirv.ptr<f32, Function>
-// CHECK: spirv.mlir.loop {
-// CHECK:    spirv.Branch ^[[HEADER:.*]](%[[C0_I32_0]], %[[C0_F32]] : i32, f32)
-// CHECK:  ^[[HEADER]](%[[INDVAR_0:.*]]: i32, %[[INDVAR_1:.*]]: f32):
-// CHECK:    %[[SLESSTHAN:.*]] = spirv.SLessThan %[[INDVAR_0]], %[[C4_I32_0]] : i32
-// CHECK:    spirv.BranchConditional %[[SLESSTHAN]], ^[[BODY:.*]], ^[[MERGE:.*]]
-// CHECK:  ^[[BODY]]:
-// CHECK:    %[[FADD:.*]] = spirv.FAdd %[[INDVAR_1]], %[[C1_F32]]  : f32
-// CHECK:    %[[INSERT:.*]] = spirv.CompositeInsert %[[FADD]], %[[VEC]][0 : i32] : f32 into vector<4xf32>
-// CHECK:    spirv.Store "Function" %[[VARIABLE]], %[[FADD]] : f32
-// CHECK:    %[[IADD:.*]] = spirv.IAdd %[[INDVAR_0]], %[[C1_I32]] : i32
-// CHECK:    spirv.Branch ^[[HEADER]](%[[IADD]], %[[FADD]] : i32, f32)
-// CHECK:  ^[[MERGE]]:
-// CHECK:    spirv.mlir.merge
-// CHECK:  }
-// CHECK:  %[[LOAD:.*]] = spirv.Load "Function" %[[VARIABLE]] : f32
-// CHECK:  %[[UNDEF:.*]] = spirv.Undef : f32
-// CHECK:  spirv.ReturnValue %[[UNDEF]] : f32
-func.func @combined() -> f32 {
-  %c0_f32 = arith.constant 0.0 : f32
-  %c1_f32 = arith.constant 1.0 : f32
-  %c0_i32 = arith.constant 0 : i32
-  %c4_i32 = arith.constant 4 : i32
-  %lb = index.casts %c0_i32 : i32 to index
-  %ub = index.casts %c4_i32 : i32 to index
-  %step = arith.constant 1 : index
-  %buf = vector.broadcast %c1_f32 : f32 to vector<4xf32>
-  scf.for %iv = %lb to %ub step %step iter_args(%sum_iter = %c0_f32) -> f32 {
-    %t = vector.extract %buf[0] : f32 from vector<4xf32>
-    %sum_next = arith.addf %sum_iter, %t : f32
-    vector.insert %sum_next, %buf[0] : f32 into vector<4xf32>
-    scf.yield %sum_next : f32
-  }
-  %ret = ub.poison : f32
-  return %ret : f32
-}
diff --git a/mlir/test/Conversion/ConvertToSPIRV/index.mlir b/mlir/test/Conversion/ConvertToSPIRV/index.mlir
deleted file mode 100644
index db747625bc7b3..0000000000000
--- a/mlir/test/Conversion/ConvertToSPIRV/index.mlir
+++ /dev/null
@@ -1,63 +0,0 @@
-// RUN: mlir-opt %s -convert-to-spirv | FileCheck %s
-
-// CHECK-LABEL: @basic
-func.func @basic(%a: index, %b: index) {
-  // CHECK: spirv.IAdd
-  %0 = index.add %a, %b
-  // CHECK: spirv.ISub
-  %1 = index.sub %a, %b
-  // CHECK: spirv.IMul
-  %2 = index.mul %a, %b
-  // CHECK: spirv.SDiv
-  %3 = index.divs %a, %b
-  // CHECK: spirv.UDiv
-  %4 = index.divu %a, %b
-  // CHECK: spirv.SRem
-  %5 = index.rems %a, %b
-  // CHECK: spirv.UMod
-  %6 = index.remu %a, %b
-  // CHECK: spirv.GL.SMax
-  %7 = index.maxs %a, %b
-  // CHECK: spirv.GL.UMax
-  %8 = index.maxu %a, %b
-  // CHECK: spirv.GL.SMin
-  %9 = index.mins %a, %b
-  // CHECK: spirv.GL.UMin
-  %10 = index.minu %a, %b
-  // CHECK: spirv.ShiftLeftLogical
-  %11 = index.shl %a, %b
-  // CHECK: spirv.ShiftRightArithmetic
-  %12 = index.shrs %a, %b
-  // CHECK: spirv.ShiftRightLogical
-  %13 = index.shru %a, %b
-  // CHECK: spirv.BitwiseAnd
-  %14 = index.and %a, %b
-  // CHECK: spirv.BitwiseOr
-  %15 = index.or %a, %b
-  // CHECK: spirv.BitwiseXor
-  %16 = index.xor %a, %b
-  return
-}
-
-// CHECK-LABEL: @cmp
-func.func @cmp(%a : index, %b : index) {
-  // CHECK: spirv.IEqual
-  %0 = index.cmp eq(%a, %b)
-  return
-}
-
-// CHECK-LABEL: @ceildivs
-// CHECK-SAME: %[[ARG0:.*]]: i32, %[[ARG1:.*]]: i32
-// CHECK:    spirv.ReturnValue %{{.*}} : i32
-func.func @ceildivs(%n: index, %m: index) -> index {
-  %result = index.ceildivs %n, %m
-  return %result : index
-}
-
-// CHECK-LABEL: @ceildivu
-// CHECK-SAME: %[[ARG0:.*]]: i32, %[[ARG1:.*]]: i32
-// CHECK:    spirv.ReturnValue %{{.*}} : i32
-func.func @ceildivu(%n: index, %m: index) -> index {
-  %result = index.ceildivu %n, %m
-  return %result : index
-}
diff --git a/mlir/test/Conversion/ConvertToSPIRV/scf.mlir b/mlir/test/Conversion/ConvertToSPIRV/scf.mlir
deleted file mode 100644
index f619ca5771824..0000000000000
--- a/mlir/test/Conversion/ConvertToSPIRV/scf.mlir
+++ /dev/null
@@ -1,47 +0,0 @@
-// RUN: mlir-opt -convert-to-spirv %s | FileCheck %s
-
-// CHECK-LABEL: @if_yield
-// CHECK: %[[VAR:.*]] = spirv.Variable : !spirv.ptr<f32, Function>
-// CHECK:       spirv.mlir.selection {
-// CHECK-NEXT:    spirv.BranchConditional {{%.*}}, [[TRUE:\^.*]], [[FALSE:\^.*]]
-// CHECK-NEXT:  [[TRUE]]:
-// CHECK:         %[[C0TRUE:.*]] = spirv.Constant 0.000000e+00 : f32
-// CHECK:         %[[RETTRUE:.*]] = spirv.Constant 0.000000e+00 : f32
-// CHECK-DAG:     spirv.Store "Function" %[[VAR]], %[[RETTRUE]] : f32
-// CHECK:         spirv.Branch ^[[MERGE:.*]]
-// CHECK-NEXT:  [[FALSE]]:
-// CHECK:         %[[C0FALSE:.*]] = spirv.Constant 1.000000e+00 : f32
-// CHECK:         %[[RETFALSE:.*]] = spirv.Constant 2.71828175 : f32
-// CHECK-DAG:     spirv.Store "Function" %[[VAR]], %[[RETFALSE]] : f32
-// CHECK:         spirv.Branch ^[[MERGE]]
-// CHECK-NEXT:  ^[[MERGE]]:
-// CHECK:         spirv.mlir.merge
-// CHECK-NEXT:  }
-// CHECK-DAG:   %[[OUT:.*]] = spirv.Load "Function" %[[VAR]] : f32
-// CHECK:       spirv.ReturnValue %[[OUT]] : f32
-func.func @if_yield(%arg0: i1) -> f32 {
-  %0 = scf.if %arg0 -> f32 {
-    %c0 = arith.constant 0.0 : f32
-    %res = math.sqrt %c0 : f32
-    scf.yield %res : f32
-  } else {
-    %c0 = arith.constant 1.0 : f32
-    %res = math.exp %c0 : f32
-    scf.yield %res : f32
-  }
-  return %0 : f32
-}
-
-// CHECK-LABEL: @while
-func.func @while(%arg0: i32, %arg1: i32) -> i32 {
-  %c2_i32 = arith.constant 2 : i32
-  %0 = scf.while (%arg3 = %arg0) : (i32) -> (i32) {
-    %1 = arith.cmpi slt, %arg3, %arg1 : i32
-    scf.condition(%1) %arg3 : i32
-  } do {
-  ^bb0(%arg5: i32):
-    %1 = arith.muli %arg5, %c2_i32 : i32
-  ...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/96332


More information about the Mlir-commits mailing list