[llvm] Preserve range metadata when load is narrowed (PR #128144)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 21 15:34:54 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
----------------
LU-JOHN wrote:
Used ConstantRange::getMinSignedBits() to implement core logic.
https://github.com/llvm/llvm-project/pull/128144
More information about the llvm-commits
mailing list