[llvm] [SelectionDAG] Salvage debuginfo when combining load and sext instrs. (PR #169779)
Orlando Cazalet-Hyams via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 8 11:56:25 PST 2025
================
@@ -14455,15 +14458,31 @@ static SDValue tryToFoldExtOfLoad(SelectionDAG &DAG, DAGCombiner &Combiner,
LN0->getBasePtr(), N0.getValueType(),
LN0->getMemOperand());
Combiner.ExtendSetCCUses(SetCCs, N0, ExtLoad, ExtOpc);
+
// If the load value is used only by N, replace it via CombineTo N.
- bool NoReplaceTrunc = SDValue(LN0, 0).hasOneUse();
+ SDValue OldLoadVal(LN0, 0);
+ SDValue OldExtValue(N, 0);
+ bool NoReplaceTrunc = OldLoadVal.hasOneUse();
Combiner.CombineTo(N, ExtLoad);
+
if (NoReplaceTrunc) {
+ if (LN0->getHasDebugValue()) {
+ DAG.transferDbgValues(OldLoadVal, ExtLoad);
+ DAG.salvageDebugInfo(*ExtLoad.getNode());
----------------
OCHyams wrote:
Hmm, we typically salvage instructions that are going to be deleted, but if I'm reading this right `ExtLoad` is the new node. So salvaging it here looks a bit odd. Same with the `Trunc` in the other `if` branch.
Sorry, I fear I may have lead you astray with the question about whether this should be moved to the salvaging code.
In this case, maybe specialised code does actually make sense. What do you think?
https://github.com/llvm/llvm-project/pull/169779
More information about the llvm-commits
mailing list