Index: mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td =================================================================== --- mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td +++ mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td @@ -771,6 +771,7 @@ def LLVM_CopySignOp : LLVM_BinarySameArgsIntrinsicOp<"copysign">; def LLVM_CosOp : LLVM_UnaryIntrinsicOp<"cos">; def LLVM_ExpOp : LLVM_UnaryIntrinsicOp<"exp">; +def LLVM_Exp2Op : LLVM_UnaryIntrinsicOp<"exp2">; def LLVM_FAbsOp : LLVM_UnaryIntrinsicOp<"fabs">; def LLVM_FCeilOp : LLVM_UnaryIntrinsicOp<"ceil">; def LLVM_FMAOp : LLVM_TernarySameArgsIntrinsicOp<"fma">; Index: mlir/include/mlir/Dialect/StandardOps/IR/Ops.td =================================================================== --- mlir/include/mlir/Dialect/StandardOps/IR/Ops.td +++ mlir/include/mlir/Dialect/StandardOps/IR/Ops.td @@ -923,6 +923,14 @@ let summary = "base-e exponential of the specified value"; } +//===----------------------------------------------------------------------===// +// ExpOp +//===----------------------------------------------------------------------===// + +def Exp2Op : FloatUnaryOp<"exp2"> { + let summary = "base-2 exponential of the specified value"; +} + //===----------------------------------------------------------------------===// // ExtractElementOp //===----------------------------------------------------------------------===// Index: mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp =================================================================== --- mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp +++ mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp @@ -1222,6 +1222,7 @@ using CosOpLowering = VectorConvertToLLVMPattern; using DivFOpLowering = VectorConvertToLLVMPattern; using ExpOpLowering = VectorConvertToLLVMPattern; +using Exp2OpLowering = VectorConvertToLLVMPattern; using Log10OpLowering = VectorConvertToLLVMPattern; using Log2OpLowering = VectorConvertToLLVMPattern; using LogOpLowering = VectorConvertToLLVMPattern; @@ -2649,6 +2650,7 @@ DialectCastOpLowering, DivFOpLowering, ExpOpLowering, + Exp2OpLowering, LogOpLowering, Log10OpLowering, Log2OpLowering, Index: mlir/test/Conversion/StandardToLLVM/convert-to-llvmir.mlir =================================================================== --- mlir/test/Conversion/StandardToLLVM/convert-to-llvmir.mlir +++ mlir/test/Conversion/StandardToLLVM/convert-to-llvmir.mlir @@ -485,18 +485,20 @@ %12 = xor %arg2, %arg3 : i32 // CHECK-NEXT: %13 = "llvm.intr.exp"(%arg0) : (!llvm.float) -> !llvm.float %13 = std.exp %arg0 : f32 -// CHECK-NEXT: %14 = llvm.mlir.constant(7.900000e-01 : f64) : !llvm.double - %14 = constant 7.9e-01 : f64 -// CHECK-NEXT: %15 = llvm.shl %arg2, %arg3 : !llvm.i32 - %15 = shift_left %arg2, %arg3 : i32 -// CHECK-NEXT: %16 = llvm.ashr %arg2, %arg3 : !llvm.i32 - %16 = shift_right_signed %arg2, %arg3 : i32 -// CHECK-NEXT: %17 = llvm.lshr %arg2, %arg3 : !llvm.i32 - %17 = shift_right_unsigned %arg2, %arg3 : i32 +// CHECK-NEXT: %14 = "llvm.intr.exp2"(%arg0) : (!llvm.float) -> !llvm.float + %14 = std.exp2 %arg0 : f32 +// CHECK-NEXT: %15 = llvm.mlir.constant(7.900000e-01 : f64) : !llvm.double + %15 = constant 7.9e-01 : f64 +// CHECK-NEXT: %16 = llvm.shl %arg2, %arg3 : !llvm.i32 + %16 = shift_left %arg2, %arg3 : i32 +// CHECK-NEXT: %17 = llvm.ashr %arg2, %arg3 : !llvm.i32 + %17 = shift_right_signed %arg2, %arg3 : i32 +// CHECK-NEXT: %18 = llvm.lshr %arg2, %arg3 : !llvm.i32 + %18 = shift_right_unsigned %arg2, %arg3 : i32 // CHECK-NEXT: %{{[0-9]+}} = "llvm.intr.sqrt"(%arg0) : (!llvm.float) -> !llvm.float - %18 = std.sqrt %arg0 : f32 + %19 = std.sqrt %arg0 : f32 // CHECK-NEXT: %{{[0-9]+}} = "llvm.intr.sqrt"(%arg4) : (!llvm.double) -> !llvm.double - %19 = std.sqrt %arg4 : f64 + %20 = std.sqrt %arg4 : f64 return %0, %4 : f32, i32 } Index: mlir/test/Target/llvmir-intrinsics.mlir =================================================================== --- mlir/test/Target/llvmir-intrinsics.mlir +++ mlir/test/Target/llvmir-intrinsics.mlir @@ -27,6 +27,15 @@ llvm.return } +// CHECK-LABEL: @exp2_test +llvm.func @exp2_test(%arg0: !llvm.float, %arg1: !llvm<"<8 x float>">) { + // CHECK: call float @llvm.exp2.f32 + "llvm.intr.exp2"(%arg0) : (!llvm.float) -> !llvm.float + // CHECK: call <8 x float> @llvm.exp2.v8f32 + "llvm.intr.exp2"(%arg1) : (!llvm<"<8 x float>">) -> !llvm<"<8 x float>"> + llvm.return +} + // CHECK-LABEL: @log_test llvm.func @log_test(%arg0: !llvm.float, %arg1: !llvm<"<8 x float>">) { // CHECK: call float @llvm.log.f32