[PATCH] D152718: [SelectionDAG][AArch64] Legalize FMAXIMUM/FMINIMUM

Anna Thomas via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 12 09:24:20 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb2195bc771ed: [SelectionDAG][AArch64] Legalize FMAXIMUM/FMINIMUM (authored by anna).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152718/new/

https://reviews.llvm.org/D152718

Files:
  llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
  llvm/test/CodeGen/AArch64/fmaximum-legalization.ll


Index: llvm/test/CodeGen/AArch64/fmaximum-legalization.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/AArch64/fmaximum-legalization.ll
@@ -0,0 +1,43 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
+; RUN: llc < %s -mtriple=aarch64-none-linux-gnu -mattr=+neon | FileCheck %s --check-prefix=CHECK
+
+declare <4 x half> @llvm.maximum.v4f16(<4 x half>, <4 x half>)
+
+declare <2 x fp128> @llvm.maximum.v2f128(<2 x fp128>, <2 x fp128>)
+
+; Fixes PR63267
+define <4 x half> @fmaximum_v4f16(<4 x half> %x, <4 x half> %y) {
+; CHECK-LABEL: fmaximum_v4f16:
+; CHECK:       // %bb.0:
+; CHECK-NEXT:    // kill: def $d1 killed $d1 def $q1
+; CHECK-NEXT:    // kill: def $d0 killed $d0 def $q0
+; CHECK-NEXT:    mov h2, v1.h[1]
+; CHECK-NEXT:    mov h3, v0.h[1]
+; CHECK-NEXT:    fcvt s4, h1
+; CHECK-NEXT:    fcvt s5, h0
+; CHECK-NEXT:    mov h6, v1.h[2]
+; CHECK-NEXT:    mov h7, v0.h[2]
+; CHECK-NEXT:    mov h1, v1.h[3]
+; CHECK-NEXT:    fcvt s2, h2
+; CHECK-NEXT:    fcvt s3, h3
+; CHECK-NEXT:    fmax s4, s5, s4
+; CHECK-NEXT:    fcvt s5, h7
+; CHECK-NEXT:    fcvt s1, h1
+; CHECK-NEXT:    fmax s2, s3, s2
+; CHECK-NEXT:    fcvt s3, h6
+; CHECK-NEXT:    mov h6, v0.h[3]
+; CHECK-NEXT:    fcvt h0, s4
+; CHECK-NEXT:    fcvt h2, s2
+; CHECK-NEXT:    fmax s3, s5, s3
+; CHECK-NEXT:    fcvt s4, h6
+; CHECK-NEXT:    mov v0.h[1], v2.h[0]
+; CHECK-NEXT:    fcvt h2, s3
+; CHECK-NEXT:    fmax s1, s4, s1
+; CHECK-NEXT:    mov v0.h[2], v2.h[0]
+; CHECK-NEXT:    fcvt h1, s1
+; CHECK-NEXT:    mov v0.h[3], v1.h[0]
+; CHECK-NEXT:    // kill: def $d0 killed $d0 killed $q0
+; CHECK-NEXT:    ret
+  %r = call <4 x half> @llvm.maximum.v4f16(<4 x half> %x, <4 x half> %y)
+  ret <4 x half> %r
+}
Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -4167,6 +4167,9 @@
                     RTLIB::FMIN_F80, RTLIB::FMIN_F128,
                     RTLIB::FMIN_PPCF128, Results);
     break;
+  // FIXME: We do not have libcalls for FMAXIMUM and FMINIMUM. So, we cannot use
+  // libcall legalization for these nodes, but there is no default expasion for
+  // these nodes either (see PR63267 for example).
   case ISD::FMAXNUM:
   case ISD::STRICT_FMAXNUM:
     ExpandFPLibCall(Node, RTLIB::FMAX_F32, RTLIB::FMAX_F64,
@@ -4951,6 +4954,8 @@
   case ISD::FREM:
   case ISD::FMINNUM:
   case ISD::FMAXNUM:
+  case ISD::FMINIMUM:
+  case ISD::FMAXIMUM:
   case ISD::FPOW:
     Tmp1 = DAG.getNode(ISD::FP_EXTEND, dl, NVT, Node->getOperand(0));
     Tmp2 = DAG.getNode(ISD::FP_EXTEND, dl, NVT, Node->getOperand(1));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152718.530545.patch
Type: text/x-patch
Size: 2775 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230612/ae344852/attachment-0001.bin>


More information about the llvm-commits mailing list