Index: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp =================================================================== --- llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -1447,6 +1447,8 @@ setOperationAction(ISD::VECREDUCE_FADD, VT, Custom); setOperationAction(ISD::VECREDUCE_FMAX, VT, Custom); setOperationAction(ISD::VECREDUCE_FMIN, VT, Custom); + setOperationAction(ISD::VECREDUCE_FMAXIMUM, VT, Custom); + setOperationAction(ISD::VECREDUCE_FMINIMUM, VT, Custom); setOperationAction(ISD::VECREDUCE_SEQ_FADD, VT, Custom); setOperationAction(ISD::VECTOR_SPLICE, VT, Custom); setOperationAction(ISD::VECTOR_DEINTERLEAVE, VT, Custom); @@ -5976,6 +5978,8 @@ case ISD::VECREDUCE_FADD: case ISD::VECREDUCE_FMAX: case ISD::VECREDUCE_FMIN: + case ISD::VECREDUCE_FMAXIMUM: + case ISD::VECREDUCE_FMINIMUM: return LowerVECREDUCE(Op, DAG); case ISD::ATOMIC_LOAD_SUB: return LowerATOMIC_LOAD_SUB(Op, DAG); @@ -13571,6 +13575,10 @@ return LowerReductionToSVE(AArch64ISD::FMAXNMV_PRED, Op, DAG); case ISD::VECREDUCE_FMIN: return LowerReductionToSVE(AArch64ISD::FMINNMV_PRED, Op, DAG); + case ISD::VECREDUCE_FMAXIMUM: + return LowerReductionToSVE(AArch64ISD::FMAXV_PRED, Op, DAG); + case ISD::VECREDUCE_FMINIMUM: + return LowerReductionToSVE(AArch64ISD::FMINV_PRED, Op, DAG); default: llvm_unreachable("Unhandled fixed length reduction"); } Index: llvm/test/CodeGen/AArch64/sve-fp-reduce.ll =================================================================== --- llvm/test/CodeGen/AArch64/sve-fp-reduce.ll +++ llvm/test/CodeGen/AArch64/sve-fp-reduce.ll @@ -47,7 +47,7 @@ ; CHECK-NEXT: .cfi_offset w29, -16 ; CHECK-NEXT: addvl sp, sp, #-1 ; CHECK-NEXT: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x08, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 8 * VG -; CHECK-NEXT: mov w8, #32768 +; CHECK-NEXT: mov w8, #32768 // =0x8000 ; CHECK-NEXT: ptrue p0.h ; CHECK-NEXT: ptrue p1.d ; CHECK-NEXT: st1h { z0.h }, p0, [sp] @@ -72,7 +72,7 @@ ; CHECK-NEXT: .cfi_offset w29, -16 ; CHECK-NEXT: addvl sp, sp, #-3 ; CHECK-NEXT: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x18, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 24 * VG -; CHECK-NEXT: mov w8, #32768 +; CHECK-NEXT: mov w8, #32768 // =0x8000 ; CHECK-NEXT: ptrue p0.h ; CHECK-NEXT: ptrue p1.d ; CHECK-NEXT: st1h { z1.h }, p0, [sp] @@ -100,7 +100,7 @@ define half @fadda_nxv12f16( %v, half %s) { ; CHECK-LABEL: fadda_nxv12f16: ; CHECK: // %bb.0: -; CHECK-NEXT: mov w8, #32768 +; CHECK-NEXT: mov w8, #32768 // =0x8000 ; CHECK-NEXT: // kill: def $h2 killed $h2 def $z2 ; CHECK-NEXT: uunpklo z1.s, z1.h ; CHECK-NEXT: ptrue p0.h @@ -218,7 +218,7 @@ ret double %res } -; FMAXV +; FMAXNMV define half @fmaxv_nxv2f16( %a) { ; CHECK-LABEL: fmaxv_nxv2f16: @@ -286,7 +286,7 @@ ret double %res } -; FMINV +; FMINNMV define half @fminv_nxv2f16( %a) { ; CHECK-LABEL: fminv_nxv2f16: @@ -354,6 +354,145 @@ ret double %res } + + + +; FMAXV + +define half @fmaximumv_nxv2f16( %a) { +; CHECK-LABEL: fmaximumv_nxv2f16: +; CHECK: // %bb.0: +; CHECK-NEXT: ptrue p0.d +; CHECK-NEXT: fmaxv h0, p0, z0.h +; CHECK-NEXT: // kill: def $h0 killed $h0 killed $z0 +; CHECK-NEXT: ret + %res = call half @llvm.vector.reduce.fmaximum.nxv2f16( %a) + ret half %res +} + +define half @fmaximumv_nxv4f16( %a) { +; CHECK-LABEL: fmaximumv_nxv4f16: +; CHECK: // %bb.0: +; CHECK-NEXT: ptrue p0.s +; CHECK-NEXT: fmaxv h0, p0, z0.h +; CHECK-NEXT: // kill: def $h0 killed $h0 killed $z0 +; CHECK-NEXT: ret + %res = call half @llvm.vector.reduce.fmaximum.nxv4f16( %a) + ret half %res +} + +define half @fmaximumv_nxv8f16( %a) { +; CHECK-LABEL: fmaximumv_nxv8f16: +; CHECK: // %bb.0: +; CHECK-NEXT: ptrue p0.h +; CHECK-NEXT: fmaxv h0, p0, z0.h +; CHECK-NEXT: // kill: def $h0 killed $h0 killed $z0 +; CHECK-NEXT: ret + %res = call half @llvm.vector.reduce.fmaximum.nxv8f16( %a) + ret half %res +} + +define float @fmaximumv_nxv2f32( %a) { +; CHECK-LABEL: fmaximumv_nxv2f32: +; CHECK: // %bb.0: +; CHECK-NEXT: ptrue p0.d +; CHECK-NEXT: fmaxv s0, p0, z0.s +; CHECK-NEXT: // kill: def $s0 killed $s0 killed $z0 +; CHECK-NEXT: ret + %res = call float @llvm.vector.reduce.fmaximum.nxv2f32( %a) + ret float %res +} + +define float @fmaximumv_nxv4f32( %a) { +; CHECK-LABEL: fmaximumv_nxv4f32: +; CHECK: // %bb.0: +; CHECK-NEXT: ptrue p0.s +; CHECK-NEXT: fmaxv s0, p0, z0.s +; CHECK-NEXT: // kill: def $s0 killed $s0 killed $z0 +; CHECK-NEXT: ret + %res = call float @llvm.vector.reduce.fmaximum.nxv4f32( %a) + ret float %res +} + +define double @fmaximumv_nxv2f64( %a) { +; CHECK-LABEL: fmaximumv_nxv2f64: +; CHECK: // %bb.0: +; CHECK-NEXT: ptrue p0.d +; CHECK-NEXT: fmaxv d0, p0, z0.d +; CHECK-NEXT: // kill: def $d0 killed $d0 killed $z0 +; CHECK-NEXT: ret + %res = call double @llvm.vector.reduce.fmaximum.nxv2f64( %a) + ret double %res +} + +; FMINV + +define half @fminimumv_nxv2f16( %a) { +; CHECK-LABEL: fminimumv_nxv2f16: +; CHECK: // %bb.0: +; CHECK-NEXT: ptrue p0.d +; CHECK-NEXT: fminv h0, p0, z0.h +; CHECK-NEXT: // kill: def $h0 killed $h0 killed $z0 +; CHECK-NEXT: ret + %res = call half @llvm.vector.reduce.fminimum.nxv2f16( %a) + ret half %res +} + +define half @fminimumv_nxv4f16( %a) { +; CHECK-LABEL: fminimumv_nxv4f16: +; CHECK: // %bb.0: +; CHECK-NEXT: ptrue p0.s +; CHECK-NEXT: fminv h0, p0, z0.h +; CHECK-NEXT: // kill: def $h0 killed $h0 killed $z0 +; CHECK-NEXT: ret + %res = call half @llvm.vector.reduce.fminimum.nxv4f16( %a) + ret half %res +} + +define half @fminimumv_nxv8f16( %a) { +; CHECK-LABEL: fminimumv_nxv8f16: +; CHECK: // %bb.0: +; CHECK-NEXT: ptrue p0.h +; CHECK-NEXT: fminv h0, p0, z0.h +; CHECK-NEXT: // kill: def $h0 killed $h0 killed $z0 +; CHECK-NEXT: ret + %res = call half @llvm.vector.reduce.fminimum.nxv8f16( %a) + ret half %res +} + +define float @fminimumv_nxv2f32( %a) { +; CHECK-LABEL: fminimumv_nxv2f32: +; CHECK: // %bb.0: +; CHECK-NEXT: ptrue p0.d +; CHECK-NEXT: fminv s0, p0, z0.s +; CHECK-NEXT: // kill: def $s0 killed $s0 killed $z0 +; CHECK-NEXT: ret + %res = call float @llvm.vector.reduce.fminimum.nxv2f32( %a) + ret float %res +} + +define float @fminimumv_nxv4f32( %a) { +; CHECK-LABEL: fminimumv_nxv4f32: +; CHECK: // %bb.0: +; CHECK-NEXT: ptrue p0.s +; CHECK-NEXT: fminv s0, p0, z0.s +; CHECK-NEXT: // kill: def $s0 killed $s0 killed $z0 +; CHECK-NEXT: ret + %res = call float @llvm.vector.reduce.fminimum.nxv4f32( %a) + ret float %res +} + +define double @fminimumv_nxv2f64( %a) { +; CHECK-LABEL: fminimumv_nxv2f64: +; CHECK: // %bb.0: +; CHECK-NEXT: ptrue p0.d +; CHECK-NEXT: fminv d0, p0, z0.d +; CHECK-NEXT: // kill: def $d0 killed $d0 killed $z0 +; CHECK-NEXT: ret + %res = call double @llvm.vector.reduce.fminimum.nxv2f64( %a) + ret double %res +} + define float @fadd_reduct_reassoc_v4v8f32( %a, %b) { ; CHECK-LABEL: fadd_reduct_reassoc_v4v8f32: ; CHECK: // %bb.0: @@ -393,3 +532,17 @@ declare float @llvm.vector.reduce.fmin.nxv2f32() declare float @llvm.vector.reduce.fmin.nxv4f32() declare double @llvm.vector.reduce.fmin.nxv2f64() + +declare half @llvm.vector.reduce.fmaximum.nxv2f16() +declare half @llvm.vector.reduce.fmaximum.nxv4f16() +declare half @llvm.vector.reduce.fmaximum.nxv8f16() +declare float @llvm.vector.reduce.fmaximum.nxv2f32() +declare float @llvm.vector.reduce.fmaximum.nxv4f32() +declare double @llvm.vector.reduce.fmaximum.nxv2f64() + +declare half @llvm.vector.reduce.fminimum.nxv2f16() +declare half @llvm.vector.reduce.fminimum.nxv4f16() +declare half @llvm.vector.reduce.fminimum.nxv8f16() +declare float @llvm.vector.reduce.fminimum.nxv2f32() +declare float @llvm.vector.reduce.fminimum.nxv4f32() +declare double @llvm.vector.reduce.fminimum.nxv2f64() Index: llvm/test/CodeGen/AArch64/sve-split-fp-reduce.ll =================================================================== --- llvm/test/CodeGen/AArch64/sve-split-fp-reduce.ll +++ llvm/test/CodeGen/AArch64/sve-split-fp-reduce.ll @@ -32,7 +32,7 @@ ret float %res } -; FMAXV +; FMAXMNV define double @fmaxv_nxv8f64( %a) { ; CHECK-LABEL: fmaxv_nxv8f64: @@ -48,7 +48,7 @@ ret double %res } -; FMINV +; FMINNMV define half @fminv_nxv16f16( %a) { ; CHECK-LABEL: fminv_nxv16f16: @@ -62,9 +62,40 @@ ret half %res } +; FMAXV + +define double @fmaximumv_nxv8f64( %a) { +; CHECK-LABEL: fmaximumv_nxv8f64: +; CHECK: // %bb.0: +; CHECK-NEXT: ptrue p0.d +; CHECK-NEXT: fmax z1.d, p0/m, z1.d, z3.d +; CHECK-NEXT: fmax z0.d, p0/m, z0.d, z2.d +; CHECK-NEXT: fmax z0.d, p0/m, z0.d, z1.d +; CHECK-NEXT: fmaxv d0, p0, z0.d +; CHECK-NEXT: // kill: def $d0 killed $d0 killed $z0 +; CHECK-NEXT: ret + %res = call double @llvm.vector.reduce.fmaximum.nxv8f64( %a) + ret double %res +} + +; FMINV + +define half @fminimumv_nxv16f16( %a) { +; CHECK-LABEL: fminimumv_nxv16f16: +; CHECK: // %bb.0: +; CHECK-NEXT: ptrue p0.h +; CHECK-NEXT: fmin z0.h, p0/m, z0.h, z1.h +; CHECK-NEXT: fminv h0, p0, z0.h +; CHECK-NEXT: // kill: def $h0 killed $h0 killed $z0 +; CHECK-NEXT: ret + %res = call half @llvm.vector.reduce.fminimum.nxv16f16( %a) + ret half %res +} + declare double @llvm.vector.reduce.fadd.nxv8f64(double, ) declare float @llvm.vector.reduce.fadd.nxv8f32(float, ) declare double @llvm.vector.reduce.fmax.nxv8f64() - declare half @llvm.vector.reduce.fmin.nxv16f16() +declare double @llvm.vector.reduce.fmaximum.nxv8f64() +declare half @llvm.vector.reduce.fminimum.nxv16f16()