[PATCH] D75834: [NFC][PowerPC] Simplify the logic in lower select_cc

qshanz via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 8 20:14:52 PDT 2020


steven.zhang created this revision.
steven.zhang added a reviewer: PowerPC.
steven.zhang added a project: PowerPC.
Herald added subscribers: shchenz, wuzish, jsji, kbarton, hiraditya, nemanjai.
Herald added a project: LLVM.

The logic in select_cc is messy and hard to follow. This is a NFC patch to simplify the logic.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75834

Files:
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp


Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -7540,15 +7540,11 @@
       !Op.getOperand(2).getValueType().isFloatingPoint())
     return Op;
 
-  bool HasNoInfs = DAG.getTarget().Options.NoInfsFPMath;
-  bool HasNoNaNs = DAG.getTarget().Options.NoNaNsFPMath;
   // We might be able to do better than this under some circumstances, but in
   // general, fsel-based lowering of select is a finite-math-only optimization.
   // For more information, see section F.3 of the 2.06 ISA specification.
   // With ISA 3.0, we have xsmaxcdp/xsmincdp which are OK to emit even in the
   // presence of infinities.
-  if (!Subtarget.hasP9Vector() && (!HasNoInfs || !HasNoNaNs))
-    return Op;
   ISD::CondCode CC = cast<CondCodeSDNode>(Op.getOperand(4))->get();
 
   EVT ResVT = Op.getValueType();
@@ -7560,10 +7556,7 @@
   if (Subtarget.hasP9Vector() && LHS == TV && RHS == FV) {
     switch (CC) {
     default:
-      // Not a min/max but with finite math, we may still be able to use fsel.
-      if (HasNoInfs && HasNoNaNs)
-        break;
-      return Op;
+      break;
     case ISD::SETOGT:
     case ISD::SETGT:
       return DAG.getNode(PPCISD::XSMAXCDP, dl, Op.getValueType(), LHS, RHS);
@@ -7571,7 +7564,10 @@
     case ISD::SETLT:
       return DAG.getNode(PPCISD::XSMINCDP, dl, Op.getValueType(), LHS, RHS);
     }
-  } else if (!HasNoInfs || !HasNoNaNs)
+  }
+
+  if (!DAG.getTarget().Options.NoInfsFPMath ||
+      !DAG.getTarget().Options.NoNaNsFPMath)
     return Op;
 
   // TODO: Propagate flags from the select rather than global settings.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75834.249025.patch
Type: text/x-patch
Size: 1724 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200309/71c20d3a/attachment.bin>


More information about the llvm-commits mailing list