diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td @@ -718,6 +718,8 @@ def LLVM_vector_reduce_fmax : LLVM_VecReductionF<"fmax">; def LLVM_vector_reduce_fmin : LLVM_VecReductionF<"fmin">; +def LLVM_vector_reduce_fmaximum : LLVM_VecReductionF<"fmaximum">; +def LLVM_vector_reduce_fminimum : LLVM_VecReductionF<"fminimum">; def LLVM_vector_reduce_fadd : LLVM_VecReductionAccF<"fadd">; def LLVM_vector_reduce_fmul : LLVM_VecReductionAccF<"fmul">; diff --git a/mlir/test/Dialect/LLVMIR/roundtrip.mlir b/mlir/test/Dialect/LLVMIR/roundtrip.mlir --- a/mlir/test/Dialect/LLVMIR/roundtrip.mlir +++ b/mlir/test/Dialect/LLVMIR/roundtrip.mlir @@ -516,6 +516,10 @@ %13 = llvm.intr.vector.reduce.fmin(%arg3) {fastmathFlags = #llvm.fastmath} : (vector<2xf32>) -> f32 // CHECK: {{.*}} = llvm.intr.vector.reduce.fmax(%arg3) {fastmathFlags = #llvm.fastmath} : (vector<2xf32>) -> f32 %14 = llvm.intr.vector.reduce.fmax(%arg3) {fastmathFlags = #llvm.fastmath} : (vector<2xf32>) -> f32 +// CHECK: {{.*}} = llvm.intr.vector.reduce.fminimum(%arg3) {fastmathFlags = #llvm.fastmath} : (vector<2xf32>) -> f32 + %15 = llvm.intr.vector.reduce.fminimum(%arg3) {fastmathFlags = #llvm.fastmath} : (vector<2xf32>) -> f32 +// CHECK: {{.*}} = llvm.intr.vector.reduce.fmaximum(%arg3) {fastmathFlags = #llvm.fastmath} : (vector<2xf32>) -> f32 + %16 = llvm.intr.vector.reduce.fmaximum(%arg3) {fastmathFlags = #llvm.fastmath} : (vector<2xf32>) -> f32 return } diff --git a/mlir/test/Integration/Dialect/LLVMIR/CPU/test-vector-reductions-fp.mlir b/mlir/test/Integration/Dialect/LLVMIR/CPU/test-vector-reductions-fp.mlir --- a/mlir/test/Integration/Dialect/LLVMIR/CPU/test-vector-reductions-fp.mlir +++ b/mlir/test/Integration/Dialect/LLVMIR/CPU/test-vector-reductions-fp.mlir @@ -35,6 +35,18 @@ llvm.call @printNewline() : () -> () // CHECK: 1 + %maximum = llvm.intr.vector.reduce.fmaximum(%v) + : (vector<4xf32>) -> f32 + llvm.call @printF32(%maximum) : (f32) -> () + llvm.call @printNewline() : () -> () + // CHECK: 4 + + %minimum = llvm.intr.vector.reduce.fminimum(%v) + : (vector<4xf32>) -> f32 + llvm.call @printF32(%minimum) : (f32) -> () + llvm.call @printNewline() : () -> () + // CHECK: 1 + %add1 = "llvm.intr.vector.reduce.fadd"(%0, %v) : (f32, vector<4xf32>) -> f32 llvm.call @printF32(%add1) : (f32) -> () diff --git a/mlir/test/Target/LLVMIR/Import/fastmath.ll b/mlir/test/Target/LLVMIR/Import/fastmath.ll --- a/mlir/test/Target/LLVMIR/Import/fastmath.ll +++ b/mlir/test/Target/LLVMIR/Import/fastmath.ll @@ -45,6 +45,8 @@ declare float @llvm.fmuladd.f32(float, float, float) declare float @llvm.vector.reduce.fmin.v2f32(<2 x float>) declare float @llvm.vector.reduce.fmax.v2f32(<2 x float>) +declare float @llvm.vector.reduce.fminimum.v2f32(<2 x float>) +declare float @llvm.vector.reduce.fmaximum.v2f32(<2 x float>) ; CHECK-LABEL: @fastmath_intr define void @fastmath_intr(float %arg1, i32 %arg2, <2 x float> %arg3) { @@ -60,6 +62,10 @@ %5 = call nnan float @llvm.vector.reduce.fmin.v2f32(<2 x float> %arg3) ; CHECK: %{{.*}} = llvm.intr.vector.reduce.fmax({{.*}}) {fastmathFlags = #llvm.fastmath} : (vector<2xf32>) -> f32 %6 = call nnan float @llvm.vector.reduce.fmax.v2f32(<2 x float> %arg3) + ; CHECK: %{{.*}} = llvm.intr.vector.reduce.fminimum({{.*}}) {fastmathFlags = #llvm.fastmath} : (vector<2xf32>) -> f32 + %7 = call nnan float @llvm.vector.reduce.fminimum.v2f32(<2 x float> %arg3) + ; CHECK: %{{.*}} = llvm.intr.vector.reduce.fmaximum({{.*}}) {fastmathFlags = #llvm.fastmath} : (vector<2xf32>) -> f32 + %8 = call nnan float @llvm.vector.reduce.fmaximum.v2f32(<2 x float> %arg3) ret void } diff --git a/mlir/test/Target/LLVMIR/Import/intrinsic.ll b/mlir/test/Target/LLVMIR/Import/intrinsic.ll --- a/mlir/test/Target/LLVMIR/Import/intrinsic.ll +++ b/mlir/test/Target/LLVMIR/Import/intrinsic.ll @@ -364,6 +364,10 @@ %17 = call reassoc float @llvm.vector.reduce.fmul.v8f32(float %0, <8 x float> %1) ; CHECK: "llvm.intr.vector.reduce.xor"(%{{.*}}) : (vector<8xi32>) -> i32 %18 = call i32 @llvm.vector.reduce.xor.v8i32(<8 x i32> %2) + ; CHECK: llvm.intr.vector.reduce.fmaximum(%{{.*}}) : (vector<8xf32>) -> f32 + %19 = call float @llvm.vector.reduce.fmaximum.v8f32(<8 x float> %1) + ; CHECK: llvm.intr.vector.reduce.fminimum(%{{.*}}) : (vector<8xf32>) -> f32 + %20 = call float @llvm.vector.reduce.fminimum.v8f32(<8 x float> %1) ret void } @@ -944,6 +948,8 @@ declare i32 @llvm.vector.reduce.and.v8i32(<8 x i32>) declare float @llvm.vector.reduce.fmax.v8f32(<8 x float>) declare float @llvm.vector.reduce.fmin.v8f32(<8 x float>) +declare float @llvm.vector.reduce.fmaximum.v8f32(<8 x float>) +declare float @llvm.vector.reduce.fminimum.v8f32(<8 x float>) declare i32 @llvm.vector.reduce.mul.v8i32(<8 x i32>) declare i32 @llvm.vector.reduce.or.v8i32(<8 x i32>) declare i32 @llvm.vector.reduce.smax.v8i32(<8 x i32>) diff --git a/mlir/test/Target/LLVMIR/llvmir-intrinsics.mlir b/mlir/test/Target/LLVMIR/llvmir-intrinsics.mlir --- a/mlir/test/Target/LLVMIR/llvmir-intrinsics.mlir +++ b/mlir/test/Target/LLVMIR/llvmir-intrinsics.mlir @@ -354,6 +354,10 @@ llvm.intr.vector.reduce.fmax(%arg1) : (vector<8xf32>) -> f32 // CHECK: call float @llvm.vector.reduce.fmin.v8f32 llvm.intr.vector.reduce.fmin(%arg1) : (vector<8xf32>) -> f32 + // CHECK: call float @llvm.vector.reduce.fmaximum.v8f32 + llvm.intr.vector.reduce.fmaximum(%arg1) : (vector<8xf32>) -> f32 + // CHECK: call float @llvm.vector.reduce.fminimum.v8f32 + llvm.intr.vector.reduce.fminimum(%arg1) : (vector<8xf32>) -> f32 // CHECK: call i32 @llvm.vector.reduce.mul.v8i32 "llvm.intr.vector.reduce.mul"(%arg2) : (vector<8xi32>) -> i32 // CHECK: call i32 @llvm.vector.reduce.or.v8i32 diff --git a/mlir/test/Target/LLVMIR/llvmir.mlir b/mlir/test/Target/LLVMIR/llvmir.mlir --- a/mlir/test/Target/LLVMIR/llvmir.mlir +++ b/mlir/test/Target/LLVMIR/llvmir.mlir @@ -2011,10 +2011,14 @@ %21 = llvm.intr.vector.reduce.fmax(%arg1) {fastmathFlags = #llvm.fastmath} : (vector<2xf32>) -> f32 %22 = llvm.intr.vector.reduce.fmin(%arg1) {fastmathFlags = #llvm.fastmath} : (vector<2xf32>) -> f32 +// CHECK: call nnan float @llvm.vector.reduce.fmaximum.v2f32(<2 x float> {{.*}}) +// CHECK: call nnan float @llvm.vector.reduce.fminimum.v2f32(<2 x float> {{.*}}) + %23 = llvm.intr.vector.reduce.fmaximum(%arg1) {fastmathFlags = #llvm.fastmath} : (vector<2xf32>) -> f32 + %24 = llvm.intr.vector.reduce.fminimum(%arg1) {fastmathFlags = #llvm.fastmath} : (vector<2xf32>) -> f32 - %23 = llvm.mlir.constant(true) : i1 + %25 = llvm.mlir.constant(true) : i1 // CHECK: select contract i1 - %24 = llvm.select %23, %arg0, %20 {fastmathFlags = #llvm.fastmath} : i1, f32 + %26 = llvm.select %25, %arg0, %20 {fastmathFlags = #llvm.fastmath} : i1, f32 llvm.return }