[PATCH] D54649: [FPEnv] Rough out constrained FCmp intrinsics

Cameron McInally via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 4 08:17:43 PST 2018


cameron.mcinally added a comment.

Old patch:

  Index: lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
  ===================================================================
  --- lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
  +++ lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
  @@ -1198,30 +1199,36 @@
       case TargetLowering::Legal:
         LLVM_DEBUG(dbgs() << "Legal node: nothing to do\n");
         return;
  -    case TargetLowering::Custom:
  +    case TargetLowering::Custom: {
         LLVM_DEBUG(dbgs() << "Trying custom legalization\n");
  +      SDNode *N = Node;
  +
  +      if (N->isStrictFPOpcode())
  +        N = DAG.mutateStrictFPToFP(Node); 
  +
         // FIXME: The handling for custom lowering with multiple results is
         // a complete mess.
  -      if (SDValue Res = TLI.LowerOperation(SDValue(Node, 0), DAG)) {
  -        if (!(Res.getNode() != Node || Res.getResNo() != 0))
  +      if (SDValue Res = TLI.LowerOperation(SDValue(N, 0), DAG)) {
  +        if (!(Res.getNode() != N || Res.getResNo() != 0))
             return;
   
  -        if (Node->getNumValues() == 1) {
  +        if (N->getNumValues() == 1) {
             LLVM_DEBUG(dbgs() << "Successfully custom legalized node\n");
             // We can just directly replace this node with the lowered value.
  -          ReplaceNode(SDValue(Node, 0), Res);
  +          ReplaceNode(SDValue(N, 0), Res);
             return;
           }
   
           SmallVector<SDValue, 8> ResultVals;
  -        for (unsigned i = 0, e = Node->getNumValues(); i != e; ++i)
  +        for (unsigned i = 0, e = N->getNumValues(); i != e; ++i)
             ResultVals.push_back(Res.getValue(i));
           LLVM_DEBUG(dbgs() << "Successfully custom legalized node\n");
  -        ReplaceNode(Node, ResultVals.data());
  +        ReplaceNode(N, ResultVals.data());
           return;
         }

I think I prefer the backend solution since it hides the weirdness in the LowerSTRICT_FSETCC(...) function:

  SDValue X86TargetLowering::LowerSTRICT_FSETCC(SDValue Op, SelectionDAG &DAG) const {
    // Mutate away for now...
    Op = SDValue(DAG.mutateStrictFPToFP(Op.getNode()), 0);
    return LowerSETCC(Op, DAG);
  }


Repository:
  rL LLVM

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

https://reviews.llvm.org/D54649





More information about the llvm-commits mailing list