<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/62234>62234</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [DAGCombiner] Getting wrong value type for node with multiple results
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          barakgla
      </td>
    </tr>
</table>

<pre>
    Hi ,

I encountered some strange code after the patch [D122875](https://reviews.llvm.org/D122875) was merged.
The relevant code is in function `SimplifyVCastOp` in DAGCombiner.cpp :

```
....
/// Visit a vector cast operation, like FP_EXTEND.
SDValue DAGCombiner::SimplifyVCastOp(SDNode *N, const SDLoc &DL) {
  EVT VT = N->getValueType(0);
  assert(VT.isVector() && "SimplifyVCastOp only works on vectors!");
  EVT EltVT = VT.getVectorElementType();
  unsigned Opcode = N->getOpcode();

 SDValue N0 = N->getOperand(0);
  EVT SrcVT = N0->getValueType(0);
  EVT SrcEltVT = SrcVT.getVectorElementType();
....
```

Especially the line : `EVT SrcVT = N0->getValueType(0);`

If the node has multiple results , Isn't the result operand is not guarantee to be operand number 0 ?
>From my understanding , the result operand could be other operand if there are multiple results .

For example , if we will look at a reduced DAG of a failed test of mine :

```
...
t42: v8i32 = zero_extend t48:1
...
  t48: i32,v8i16,v4i32,ch = CUSTOM_LOAD<(load (s128) from %ir.4, align 4, !tbaa !4, !alias.scope !8, !noalias !13, addrspace 3)> t0, t2
...
```

The CUSTOM_LOAD node has multiple results but `N0->getValueType(0)` will return i32 , but the result value type is v8i16, which causing a crash because `SrcVT` is not a vector type but `getVectorElementType` demands that `SrcVT` will be a vector type.

I don't how to make a reproducer for this issue but I hope my example and explanation is enough.



</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVk2P2zYQ_TX0ZRBBomxZPvjgWHa6QLpbYF2jt4CSxhK7FCmQlB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