[llvm] [AMDGPU] In VectorLegalizer::Expand, if UnrollVectorOp returns Load, … (PR #88475)

via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 12 12:28:26 PDT 2024


================
@@ -1159,8 +1159,12 @@ void VectorLegalizer::Expand(SDNode *Node, SmallVectorImpl<SDValue> &Results) {
   }
 
   SDValue Unrolled = DAG.UnrollVectorOp(Node);
-  for (unsigned I = 0, E = Unrolled->getNumValues(); I != E; ++I)
-    Results.push_back(Unrolled.getValue(I));
+  const LoadSDNode *Ld = dyn_cast<LoadSDNode>(Unrolled.getNode());
+  if (Ld)
+    Results.push_back(Unrolled);
+  else
+    for (unsigned I = 0, E = Unrolled->getNumValues(); I != E; ++I)
+      Results.push_back(Unrolled.getValue(I));
----------------
bcahoon wrote:

the any_extend (t32) is being unrolled. The last line in UnrollVectorOps calls getBuildVector with the two extract_vector_elt expressions (t35, t37). Since those extract_vector_elt reference the same vector (t39) and extract consecutive indices, the FoldBUILD_VECTOR function returns the load (t39). So, the result from UnrollVectorOps contains two values.

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


More information about the llvm-commits mailing list