[llvm] [SelectionDAG] Fix result index and vector width in unrollExpandedOp (PR #225886)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 24 06:28:37 PDT 2026


================
@@ -5234,13 +5234,15 @@ void DAGTypeLegalizer::WidenVectorResult(SDNode *N, unsigned ResNo) {
     // elements. If the wide vector op is eventually going to be expanded to
     // scalar libcalls, then unroll into scalar ops now to avoid unnecessary
     // libcalls on the undef elements.
-    EVT VT = N->getValueType(0);
-    EVT WideVecVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
+    EVT ResVT = N->getValueType(ResNo);
+    EVT WideVecVT = TLI.getTypeToTransformTo(*DAG.getContext(), ResVT);
+    EVT VT0 = N->getValueType(0);
     if (!TLI.isOperationLegalOrCustomOrPromote(N->getOpcode(), WideVecVT) &&
-        TLI.isOperationExpandOrLibCall(N->getOpcode(), VT.getScalarType())) {
-      Res = DAG.UnrollVectorOp(N, WideVecVT.getVectorNumElements());
+        TLI.isOperationExpandOrLibCall(N->getOpcode(), VT0.getScalarType())) {
+      SDValue Unrolled = DAG.UnrollVectorOp(N, WideVecVT.getVectorNumElements());
+      Res = SDValue(Unrolled.getNode(), ResNo);
----------------
arsenm wrote:

```suggestion
      Res = Unrolled.getValue(ResNo);)
```

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


More information about the llvm-commits mailing list