diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td @@ -843,6 +843,7 @@ def LLVM_Exp2Op : LLVM_UnaryIntrinsicOp<"exp2">; def LLVM_FAbsOp : LLVM_UnaryIntrinsicOp<"fabs">; def LLVM_FCeilOp : LLVM_UnaryIntrinsicOp<"ceil">; +def LLVM_FFloorOp : LLVM_UnaryIntrinsicOp<"floor">; def LLVM_FMAOp : LLVM_TernarySameArgsIntrinsicOp<"fma">; def LLVM_FMulAddOp : LLVM_TernarySameArgsIntrinsicOp<"fmuladd">; def LLVM_Log10Op : LLVM_UnaryIntrinsicOp<"log10">; diff --git a/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp b/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp --- a/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp +++ b/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp @@ -1103,6 +1103,7 @@ DirectConversionPattern, DirectConversionPattern, DirectConversionPattern, + DirectConversionPattern, DirectConversionPattern, DirectConversionPattern, DirectConversionPattern, diff --git a/mlir/test/Conversion/SPIRVToLLVM/glsl-ops-to-llvm.mlir b/mlir/test/Conversion/SPIRVToLLVM/glsl-ops-to-llvm.mlir --- a/mlir/test/Conversion/SPIRVToLLVM/glsl-ops-to-llvm.mlir +++ b/mlir/test/Conversion/SPIRVToLLVM/glsl-ops-to-llvm.mlir @@ -48,6 +48,19 @@ return } +//===----------------------------------------------------------------------===// +// spv.GLSL.Floor +//===----------------------------------------------------------------------===// + +// CHECK-LABEL: @floor +func @floor(%arg0: f32, %arg1: vector<3xf16>) { + // CHECK: "llvm.intr.floor"(%{{.*}}) : (!llvm.float) -> !llvm.float + %0 = spv.GLSL.Floor %arg0 : f32 + // CHECK: "llvm.intr.floor"(%{{.*}}) : (!llvm<"<3 x half>">) -> !llvm<"<3 x half>"> + %1 = spv.GLSL.Floor %arg1 : vector<3xf16> + return +} + //===----------------------------------------------------------------------===// // spv.GLSL.Log //===----------------------------------------------------------------------===// diff --git a/mlir/test/Target/llvmir-intrinsics.mlir b/mlir/test/Target/llvmir-intrinsics.mlir --- a/mlir/test/Target/llvmir-intrinsics.mlir +++ b/mlir/test/Target/llvmir-intrinsics.mlir @@ -90,6 +90,15 @@ llvm.return } +// CHECK-LABEL: @floor_test +llvm.func @floor_test(%arg0: !llvm.float, %arg1: !llvm<"<8 x float>">) { + // CHECK: call float @llvm.floor.f32 + "llvm.intr.floor"(%arg0) : (!llvm.float) -> !llvm.float + // CHECK: call <8 x float> @llvm.floor.v8f32 + "llvm.intr.floor"(%arg1) : (!llvm<"<8 x float>">) -> !llvm<"<8 x float>"> + llvm.return +} + // CHECK-LABEL: @cos_test llvm.func @cos_test(%arg0: !llvm.float, %arg1: !llvm<"<8 x float>">) { // CHECK: call float @llvm.cos.f32