diff --git a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp --- a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp +++ b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp @@ -1717,6 +1717,8 @@ using DivFOpLowering = VectorConvertToLLVMPattern; using ExpOpLowering = VectorConvertToLLVMPattern; using Exp2OpLowering = VectorConvertToLLVMPattern; +using FPToSIOpLowering = VectorConvertToLLVMPattern; +using FPToUIOpLowering = VectorConvertToLLVMPattern; using FloorFOpLowering = VectorConvertToLLVMPattern; using FmaFOpLowering = VectorConvertToLLVMPattern; using Log10OpLowering = @@ -1729,6 +1731,7 @@ using OrOpLowering = VectorConvertToLLVMPattern; using PowFOpLowering = VectorConvertToLLVMPattern; using RemFOpLowering = VectorConvertToLLVMPattern; +using SIToFPOpLowering = VectorConvertToLLVMPattern; using SelectOpLowering = VectorConvertToLLVMPattern; using SignExtendIOpLowering = VectorConvertToLLVMPattern; @@ -1744,6 +1747,7 @@ using SqrtOpLowering = VectorConvertToLLVMPattern; using SubFOpLowering = VectorConvertToLLVMPattern; using SubIOpLowering = VectorConvertToLLVMPattern; +using UIToFPOpLowering = VectorConvertToLLVMPattern; using UnsignedDivIOpLowering = VectorConvertToLLVMPattern; using UnsignedRemIOpLowering = @@ -3112,31 +3116,11 @@ } }; -struct SIToFPLowering - : public OneToOneConvertToLLVMPattern { - using Super::Super; -}; - -struct UIToFPLowering - : public OneToOneConvertToLLVMPattern { - using Super::Super; -}; - struct FPExtLowering : public OneToOneConvertToLLVMPattern { using Super::Super; }; -struct FPToSILowering - : public OneToOneConvertToLLVMPattern { - using Super::Super; -}; - -struct FPToUILowering - : public OneToOneConvertToLLVMPattern { - using Super::Super; -}; - struct FPTruncLowering : public OneToOneConvertToLLVMPattern { using Super::Super; @@ -3909,8 +3893,8 @@ Log1pOpLowering, Log2OpLowering, FPExtLowering, - FPToSILowering, - FPToUILowering, + FPToSIOpLowering, + FPToUIOpLowering, FPTruncLowering, IndexCastOpLowering, MulFOpLowering, @@ -3922,7 +3906,7 @@ RemFOpLowering, ReturnOpLowering, RsqrtOpLowering, - SIToFPLowering, + SIToFPOpLowering, SelectOpLowering, ShiftLeftOpLowering, SignExtendIOpLowering, @@ -3936,7 +3920,7 @@ SubFOpLowering, SubIOpLowering, TruncateIOpLowering, - UIToFPLowering, + UIToFPOpLowering, UnsignedDivIOpLowering, UnsignedRemIOpLowering, UnsignedShiftRightOpLowering, diff --git a/mlir/test/Conversion/StandardToLLVM/convert-nd-vector-to-llvmir.mlir b/mlir/test/Conversion/StandardToLLVM/convert-nd-vector-to-llvmir.mlir --- a/mlir/test/Conversion/StandardToLLVM/convert-nd-vector-to-llvmir.mlir +++ b/mlir/test/Conversion/StandardToLLVM/convert-nd-vector-to-llvmir.mlir @@ -47,3 +47,55 @@ %0 = zexti %arg0: vector<1x2x3xi32> to vector<1x2x3xi64> return } + +// CHECK-LABEL: @sitofp +func @sitofp_vector(%arg0 : vector<1x2x3xi32>) -> vector<1x2x3xf32> { + // CHECK: llvm.mlir.undef : !llvm.array<1 x array<2 x vector<3xf32>>> + // CHECK: llvm.extractvalue %{{.*}}[0, 0] : !llvm.array<1 x array<2 x vector<3xi32>>> + // CHECK: llvm.sitofp %{{.*}} : vector<3xi32> to vector<3xf32> + // CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[0, 0] : !llvm.array<1 x array<2 x vector<3xf32>>> + // CHECK: llvm.extractvalue %{{.*}}[0, 1] : !llvm.array<1 x array<2 x vector<3xi32>>> + // CHECK: llvm.sitofp %{{.*}} : vector<3xi32> to vector<3xf32> + // CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[0, 1] : !llvm.array<1 x array<2 x vector<3xf32>>> + %0 = sitofp %arg0: vector<1x2x3xi32> to vector<1x2x3xf32> + return %0 : vector<1x2x3xf32> +} + +// CHECK-LABEL: @uitofp +func @uitofp_vector(%arg0 : vector<1x2x3xi32>) -> vector<1x2x3xf32> { + // CHECK: llvm.mlir.undef : !llvm.array<1 x array<2 x vector<3xf32>>> + // CHECK: llvm.extractvalue %{{.*}}[0, 0] : !llvm.array<1 x array<2 x vector<3xi32>>> + // CHECK: llvm.uitofp %{{.*}} : vector<3xi32> to vector<3xf32> + // CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[0, 0] : !llvm.array<1 x array<2 x vector<3xf32>>> + // CHECK: llvm.extractvalue %{{.*}}[0, 1] : !llvm.array<1 x array<2 x vector<3xi32>>> + // CHECK: llvm.uitofp %{{.*}} : vector<3xi32> to vector<3xf32> + // CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[0, 1] : !llvm.array<1 x array<2 x vector<3xf32>>> + %0 = uitofp %arg0: vector<1x2x3xi32> to vector<1x2x3xf32> + return %0 : vector<1x2x3xf32> +} + +// CHECK-LABEL: @fptosi +func @fptosi_vector(%arg0 : vector<1x2x3xf32>) -> vector<1x2x3xi32> { + // CHECK: llvm.mlir.undef : !llvm.array<1 x array<2 x vector<3xi32>>> + // CHECK: llvm.extractvalue %{{.*}}[0, 0] : !llvm.array<1 x array<2 x vector<3xf32>>> + // CHECK: llvm.fptosi %{{.*}} : vector<3xf32> to vector<3xi32> + // CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[0, 0] : !llvm.array<1 x array<2 x vector<3xi32>>> + // CHECK: llvm.extractvalue %{{.*}}[0, 1] : !llvm.array<1 x array<2 x vector<3xf32>>> + // CHECK: llvm.fptosi %{{.*}} : vector<3xf32> to vector<3xi32> + // CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[0, 1] : !llvm.array<1 x array<2 x vector<3xi32>>> + %0 = fptosi %arg0: vector<1x2x3xf32> to vector<1x2x3xi32> + return %0 : vector<1x2x3xi32> +} + +// CHECK-LABEL: @fptoui +func @fptoui_vector(%arg0 : vector<1x2x3xf32>) -> vector<1x2x3xi32> { + // CHECK: llvm.mlir.undef : !llvm.array<1 x array<2 x vector<3xi32>>> + // CHECK: llvm.extractvalue %{{.*}}[0, 0] : !llvm.array<1 x array<2 x vector<3xf32>>> + // CHECK: llvm.fptoui %{{.*}} : vector<3xf32> to vector<3xi32> + // CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[0, 0] : !llvm.array<1 x array<2 x vector<3xi32>>> + // CHECK: llvm.extractvalue %{{.*}}[0, 1] : !llvm.array<1 x array<2 x vector<3xf32>>> + // CHECK: llvm.fptoui %{{.*}} : vector<3xf32> to vector<3xi32> + // CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[0, 1] : !llvm.array<1 x array<2 x vector<3xi32>>> + %0 = fptoui %arg0: vector<1x2x3xf32> to vector<1x2x3xi32> + return %0 : vector<1x2x3xi32> +}