[PATCH] D41924: dagcombine: Transfer debug information when folding (zext (truncate x)) -> (zext (truncate x))

Adrian Prantl via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 11 09:14:50 PST 2018


aprantl added inline comments.


================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:7803
+        // Transfer the debug info; the new node is equivalent to N0.
+        DAG.transferDbgValues(N0, ZExtOrTrunc);
+        return ZExtOrTrunc;
----------------
RKSimon wrote:
> I'm surprised we need to do this - can we achieve the same by using SDLoc(N0) instead of SDLoc(N) in both the above?
Just to make sure we are talking about the same thing, I changed the code to be

```
    if (SrcVT.bitsLT(VT)) {
      if (!LegalOperations || (TLI.isOperationLegal(ISD::AND, SrcVT) &&
                               TLI.isOperationLegal(ISD::ZERO_EXTEND, VT))) {
        SDValue Op = N0.getOperand(0);
        Op = DAG.getZeroExtendInReg(Op, SDLoc(N0), MinVT.getScalarType());
        AddToWorklist(Op.getNode());
        SDValue ZExtOrTrunc = DAG.getZExtOrTrunc(Op, SDLoc(N0), VT);
        // Transfer the debug info; the new node is equivalent to N0.
        //DAG.transferDbgValues(N0, ZExtOrTrunc);
        return ZExtOrTrunc;
      }
    }
```

That does *not* preserve the DBG_VALUE.


Repository:
  rL LLVM

https://reviews.llvm.org/D41924





More information about the llvm-commits mailing list