[PATCH] D41924: dagcombine: Transfer debug information when folding (zext (truncate x)) -> (zext (truncate x))
Simon Pilgrim via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 11 09:20:59 PST 2018
RKSimon 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;
----------------
aprantl wrote:
> 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.
OK - but its very rare to have to call transferDbgValues directly like this - I just have the feeling that there is a better way......
Repository:
rL LLVM
https://reviews.llvm.org/D41924
More information about the llvm-commits
mailing list