[llvm] [DAGCombiner] Fix subvector extraction index for big-endian STLF (PR #180795)

via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 11 03:53:02 PST 2026


================
@@ -20831,8 +20831,16 @@ SDValue DAGCombiner::ForwardStoreValueToDirectLoad(LoadSDNode *LD) {
         if (!TLI.isOperationLegalOrCustom(ISD::EXTRACT_SUBVECTOR, InterVT))
           break;
 
----------------
KennethHilmersson wrote:

We entered an infinit loop in one of our down.stream testcases and needed to add this:

``
         if (!TLI.isOperationLegalOrCustom(ISD::EXTRACT_SUBVECTOR, InterVT))
           break;
 
+        // Avoid infinite loop: Don't transform loads from fixed stack objects,
+        // as legalization expands extract_subvector to such loads.
+        SDValue LDBase = LD->getBasePtr();
+        if (LDBase.getOpcode() == ISD::ADD)
+          LDBase = LDBase.getOperand(0);
+        if (LDBase.getOpcode() == ISD::FrameIndex)
+          break;
+
         // In case of big-endian the offset is normalized to zero, denoting
         // the last bit. For big-endian we need to transform the extraction
         // to the last sub-vector.
         unsigned ExtIdx = 0;

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


More information about the llvm-commits mailing list