[llvm] Preserve range metadata when load is narrowed (PR #128144)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 20 23:48:57 PST 2025
================
@@ -14903,12 +14903,39 @@ SDValue DAGCombiner::reduceLoadWidth(SDNode *N) {
AddToWorklist(NewPtr.getNode());
SDValue Load;
- if (ExtType == ISD::NON_EXTLOAD)
- Load = DAG.getLoad(VT, DL, LN0->getChain(), NewPtr,
- LN0->getPointerInfo().getWithOffset(PtrOff),
- LN0->getOriginalAlign(),
- LN0->getMemOperand()->getFlags(), LN0->getAAInfo());
- else
+ if (ExtType == ISD::NON_EXTLOAD) {
+ const MDNode *OldRanges = LN0->getRanges();
+ const MDNode *NewRanges = nullptr;
+ /* If LSBs are loaded and all bounds in the OldRanges metadata fit in
+ the narrower size, preserve the range information by translating
----------------
arsenm wrote:
Do we need new negative tests if it's not in range?
https://github.com/llvm/llvm-project/pull/128144
More information about the llvm-commits
mailing list