[llvm] [DAGCombiner] Forward vector store to vector load with extract_subvector (PR #145707)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 16 03:27:57 PDT 2025


================
@@ -19913,6 +19913,27 @@ SDValue DAGCombiner::ForwardStoreValueToDirectLoad(LoadSDNode *LD) {
     }
   }
 
+  // Loading a smaller fixed vector type from a stored larger fixed vector type
+  // can be substituted with an extract_subvector, provided the smaller type
+  // entirely contained in the larger type, and an extract_element would be
+  // legal for the given offset.
+  if (TLI.isOperationLegalOrCustom(ISD::EXTRACT_SUBVECTOR, LDType) &&
+      LDType.isFixedLengthVector() && STType.isFixedLengthVector() &&
+      !ST->isTruncatingStore() && LD->getExtensionType() == ISD::NON_EXTLOAD &&
----------------
RKSimon wrote:

This might work to simplify the logic: `ISD::isNormalLoad(LD) && ISD::isNormalStore(ST)`

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


More information about the llvm-commits mailing list