[llvm] [PowerPC] Forbid f128 SELECT_CC optimized into fsel (PR #71497)

Qiu Chaofan via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 7 00:09:51 PST 2023


https://github.com/ecnelises created https://github.com/llvm/llvm-project/pull/71497

fsel only supports f32 and f64.

>From c662b4d0349389f2a43a467c8c32cef772451fe9 Mon Sep 17 00:00:00 2001
From: Qiu Chaofan <qiucofan at cn.ibm.com>
Date: Tue, 7 Nov 2023 16:07:30 +0800
Subject: [PATCH] [PowerPC] Forbid f128 SELECT_CC optimized into fsel

fsel only supports f32 and f64.
---
 llvm/lib/Target/PowerPC/PPCISelLowering.cpp     |  3 ++-
 llvm/test/CodeGen/PowerPC/scalar-min-max-p10.ll | 17 +++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
index 5e0c2d62f5a9cb5..75c03be976ea1c9 100644
--- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -8080,7 +8080,8 @@ SDValue PPCTargetLowering::LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const {
   // For more information, see section F.3 of the 2.06 ISA specification.
   // With ISA 3.0
   if ((!DAG.getTarget().Options.NoInfsFPMath && !Flags.hasNoInfs()) ||
-      (!DAG.getTarget().Options.NoNaNsFPMath && !Flags.hasNoNaNs()))
+      (!DAG.getTarget().Options.NoNaNsFPMath && !Flags.hasNoNaNs()) ||
+      ResVT == MVT::f128)
     return Op;
 
   // If the RHS of the comparison is a 0.0, we don't need to do the
diff --git a/llvm/test/CodeGen/PowerPC/scalar-min-max-p10.ll b/llvm/test/CodeGen/PowerPC/scalar-min-max-p10.ll
index 92d534accbe4bbd..ca9bacebe7a33a9 100644
--- a/llvm/test/CodeGen/PowerPC/scalar-min-max-p10.ll
+++ b/llvm/test/CodeGen/PowerPC/scalar-min-max-p10.ll
@@ -70,3 +70,20 @@ entry:
   %0 = tail call fast fp128 @llvm.minnum.f128(fp128 %a, fp128 %b)
   ret fp128 %0
 }
+
+define fp128 @olt_sel(fp128 %a, fp128 %b) {
+; CHECK-LABEL: olt_sel:
+; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:    plxv vs36, .LCPI6_0 at PCREL(0), 1
+; CHECK-NEXT:    xscmpuqp cr0, v2, v4
+; CHECK-NEXT:    blt cr0, .LBB6_2
+; CHECK-NEXT:  # %bb.1: # %entry
+; CHECK-NEXT:    vmr v3, v4
+; CHECK-NEXT:  .LBB6_2: # %entry
+; CHECK-NEXT:    vmr v2, v3
+; CHECK-NEXT:    blr
+entry:
+  %0 = fcmp fast olt fp128 %a, 0xL00000000000000000000000000000000
+  %1 = select i1 %0, fp128 %b, fp128 0xL00000000000000000000000000000000
+  ret fp128 %1
+}



More information about the llvm-commits mailing list