[llvm] Preserve range metadata when load is narrowed (PR #128144)

via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 25 08:14:55 PST 2025


================
@@ -14903,12 +14903,31 @@ 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 the truncated ConstantRange for the OldRanges
+       metadata is not the full-set for the NewWidth then create a NewRanges
+       metadata for the truncated load */
----------------
LU-JOHN wrote:

Changed to use C++ comments.

https://github.com/llvm/llvm-project/pull/128144


More information about the llvm-commits mailing list