[llvm] [AMD][DAGCombiner] Preserve load's DebugLoc when folding bitcast(load) (PR #186766)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 24 00:19:07 PDT 2026
================
@@ -4197,9 +4197,13 @@ SDValue AMDGPUTargetLowering::performStoreCombine(SDNode *N,
//DCI.AddToWorklist(Val.getNode());
bool OtherUses = !Val.hasOneUse();
- SDValue CastVal = DAG.getNode(ISD::BITCAST, SL, NewVT, Val);
+ // Use the value's debug location for the bitcast, not the store's, so that
+ // when the bitcast is later folded into a load by visitBITCAST the resulting
+ // load retains the original load's debug location.
+ SDLoc ValDL(Val.getNode());
+ SDValue CastVal = DAG.getNode(ISD::BITCAST, ValDL, NewVT, Val);
if (OtherUses) {
- SDValue CastBack = DAG.getNode(ISD::BITCAST, SL, VT, CastVal);
+ SDValue CastBack = DAG.getNode(ISD::BITCAST, ValDL, VT, CastVal);
----------------
jwu10003 wrote:
Thanks for the feedback! Done.
https://github.com/llvm/llvm-project/pull/186766
More information about the llvm-commits
mailing list