Index: mlir/lib/Conversion/ArithToLLVM/ArithToLLVM.cpp =================================================================== --- mlir/lib/Conversion/ArithToLLVM/ArithToLLVM.cpp +++ mlir/lib/Conversion/ArithToLLVM/ArithToLLVM.cpp @@ -52,16 +52,16 @@ VectorConvertToLLVMPattern; using FPToUIOpLowering = VectorConvertToLLVMPattern; -// TODO: Add LLVM intrinsic support for fastmath -using MaxFOpLowering = VectorConvertToLLVMPattern; +using MaxFOpLowering = + VectorConvertToLLVMPattern; using MaxSIOpLowering = VectorConvertToLLVMPattern; using MaxUIOpLowering = VectorConvertToLLVMPattern; -// TODO: Add LLVM intrinsic support for fastmath -using MinFOpLowering = VectorConvertToLLVMPattern; +using MinFOpLowering = + VectorConvertToLLVMPattern; using MinSIOpLowering = VectorConvertToLLVMPattern; using MinUIOpLowering = @@ -74,9 +74,9 @@ VectorConvertToLLVMPattern; using OrIOpLowering = VectorConvertToLLVMPattern; -// TODO: Add LLVM intrinsic support for fastmath -using RemFOpLowering = VectorConvertToLLVMPattern; +using RemFOpLowering = + VectorConvertToLLVMPattern; using RemSIOpLowering = VectorConvertToLLVMPattern; using RemUIOpLowering = Index: mlir/test/Conversion/ArithToLLVM/arith-to-llvm.mlir =================================================================== --- mlir/test/Conversion/ArithToLLVM/arith-to-llvm.mlir +++ mlir/test/Conversion/ArithToLLVM/arith-to-llvm.mlir @@ -453,11 +453,11 @@ // CHECK-LABEL: @fastmath func.func @fastmath(%arg0: f32, %arg1: f32, %arg2: i32) { -// CHECK: {{.*}} = llvm.fadd %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 -// CHECK: {{.*}} = llvm.fmul %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 -// CHECK: {{.*}} = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : f32 -// CHECK: {{.*}} = llvm.fadd %arg0, %arg1 : f32 -// CHECK: {{.*}} = llvm.fadd %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 +// CHECK: llvm.fadd %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 +// CHECK: llvm.fmul %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 +// CHECK: llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : f32 +// CHECK: llvm.fadd %arg0, %arg1 : f32 +// CHECK: llvm.fadd %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 %0 = arith.addf %arg0, %arg1 fastmath : f32 %1 = arith.mulf %arg0, %arg1 fastmath : f32 %2 = arith.negf %arg0 fastmath : f32 @@ -465,3 +465,26 @@ %4 = arith.addf %arg0, %arg1 fastmath : f32 return } + +// ----- + +// CHECK-LABEL: @ops_supporting_fastmath +func.func @ops_supporting_fastmath(%arg0: f32, %arg1: f32, %arg2: i32) { +// CHECK: llvm.fadd %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %0 = arith.addf %arg0, %arg1 fastmath : f32 +// CHECK: llvm.fdiv %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %1 = arith.divf %arg0, %arg1 fastmath : f32 +// CHECK: llvm.intr.maxnum(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %2 = arith.maxf %arg0, %arg1 fastmath : f32 +// CHECK: llvm.intr.minnum(%arg0, %arg1) {fastmathFlags = #llvm.fastmath} : (f32, f32) -> f32 + %3 = arith.minf %arg0, %arg1 fastmath : f32 +// CHECK: llvm.fmul %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %4 = arith.mulf %arg0, %arg1 fastmath : f32 +// CHECK: llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath} : f32 + %5 = arith.negf %arg0 fastmath : f32 +// CHECK: llvm.frem %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %6 = arith.remf %arg0, %arg1 fastmath : f32 +// CHECK: llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath} : f32 + %7 = arith.subf %arg0, %arg1 fastmath : f32 + return +}