[PATCH] D91962: Add support for STRICT_FSETCC promotion

Thomas Preud'homme via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 23 06:13:34 PST 2020


thopre created this revision.
thopre added reviewers: craig.topper, andrew.w.kaylor, hfinkel, mehdi_amini, aemerson, javed.absar, uweigand, kbarton, cameron.mcinally.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
thopre requested review of this revision.

Add missing handling of STRICT_FSETCC promotion. This prevents assert
failure in llvm::TargetLoweringBase::getTypeToPromoteTo().


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91962

Files:
  llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp


Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -4417,7 +4417,8 @@
     OVT = Node->getOperand(0).getSimpleValueType();
   }
   if (Node->getOpcode() == ISD::STRICT_UINT_TO_FP ||
-      Node->getOpcode() == ISD::STRICT_SINT_TO_FP)
+      Node->getOpcode() == ISD::STRICT_SINT_TO_FP ||
+      Node->getOpcode() == ISD::STRICT_FSETCC)
     OVT = Node->getOperand(1).getSimpleValueType();
   if (Node->getOpcode() == ISD::BR_CC)
     OVT = Node->getOperand(2).getSimpleValueType();
@@ -4611,13 +4612,24 @@
     Results.push_back(Tmp1);
     break;
   }
-  case ISD::SETCC: {
+  case ISD::SETCC:
+  case ISD::STRICT_FSETCC: {
     unsigned ExtOp = ISD::FP_EXTEND;
     if (NVT.isInteger()) {
-      ISD::CondCode CCCode =
-        cast<CondCodeSDNode>(Node->getOperand(2))->get();
+      ISD::CondCode CCCode = cast<CondCodeSDNode>(Node->getOperand(2))->get();
       ExtOp = isSignedIntSetCC(CCCode) ? ISD::SIGN_EXTEND : ISD::ZERO_EXTEND;
     }
+    if (Node->isStrictFPOpcode()) {
+      SDValue Chain = Node->getOperand(0);
+      Tmp1 = DAG.getNode(ExtOp, dl, NVT, Node->getOperand(1));
+      Tmp2 = DAG.getNode(ExtOp, dl, NVT, Node->getOperand(2));
+      SDVTList VTs = DAG.getVTList(Node->getValueType(0), MVT::Other);
+      Results.push_back(DAG.getNode(ISD::STRICT_FSETCC, dl, VTs,
+                                    {Chain, Tmp1, Tmp2, Node->getOperand(3)},
+                                    Node->getFlags()));
+      Results.push_back(Results.back().getValue(1));
+      break;
+    }
     Tmp1 = DAG.getNode(ExtOp, dl, NVT, Node->getOperand(0));
     Tmp2 = DAG.getNode(ExtOp, dl, NVT, Node->getOperand(1));
     Results.push_back(DAG.getNode(ISD::SETCC, dl, Node->getValueType(0), Tmp1,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91962.307061.patch
Type: text/x-patch
Size: 1881 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201123/ba971e31/attachment.bin>


More information about the llvm-commits mailing list