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

    <tr>
        <th>Summary</th>
        <td>
            MLIR: overloadedResults and overloadedOperands from LLVM_IntrOpBase does not work as expected when operands have different any_types
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          petar-avramovic
      </td>
    </tr>
</table>

<pre>
    This was encountered by editing `/llvm/include/llvm/IR/IntrinsicsAMDGPU.td`

```
class AMDGPUWmmaIntrinsic<LLVMType AB, LLVMType CD> :
  Intrinsic<
    [CD], // %D
    [
      AB,               // %A
      AB, // %B
      LLVMMatchType<0>, // %C
    ],
    [IntrNoMem, IntrConvergent, IntrWillReturn, IntrNoCallback, IntrNoFree]
>;

def int_amdgcn_wmma_f32_16x16x16_f16   : AMDGPUWmmaIntrinsic<llvm_v16f16_ty, llvm_anyfloat_ty>;
```
->
`def int_amdgcn_wmma_f32_16x16x16_f16   : AMDGPUWmmaIntrinsic<llvm_anyfloat_ty, llvm_anyfloat_ty>;`



affected mlir test was `@rocdl.wmma` from `/llvm-project/mlir/test/Target/LLVMIR/rocdl.mlir`


For example this is how intrinsic looks in llvm
`any_ty_1 = @amdgcn.intrinsic (any_ty_0, any_ty_0, any_ty_1)`

See `ROCDL_wmma_f32_16x16x16_f16` from `llvm-project/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td`
There is one overloaded result and three overloaded inputs
and only arguments to LLVM_IntrOpBase that don't result in an error are
```
LLVM_IntrOpBase ...
        [0], [0, 1]
```

and full name generated by
llvm: `@amdgcn.intrinsic.any_ty_0.any_ty_1`
mlir: `@amdgcn.intrinsic.any_ty_1.any_ty_0.any_ty_0`

If mlir tablegen can't figure this out from llvm's tablegen,
I would assume that arguments should be
```

LLVM_IntrOpBase ...
        [1], [0, 0, 1]
```

Here I am referring to `AMDGPUWmmaIntrinsic<llvm_anyfloat_ty, llvm_anyfloat_ty>;` and that result and operand 2 are `second llvm_anyfloat_ty (argument 1)` from this, while operand 0 and 1 are `first llvm_anyfloat_ty(argument 0)`
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVttyozgTfhr5pisUAmPHF77wYfz_qUomW9nszqVLoAa0ERIlCTt--y1xMLbjqZ2LSbkItPrw9dcHYNaKQiEuSbImyXbCGldqs6zRMfPADoZV-iCySar5afleCgtHZgFVphvl0CCH9ATIhROqADILSbST8lCRaCdUJhuOo-DpzV-UM0JZkdnVy_Z_f_wVOO6twi0JV_11Fva_9jGTzFrolH9UFTs7IPHm-fnvl_dTjbBak2gD58fNlsTfgMS9R4BLo0EGQJL1ZkuSrbcl0Y5EOyBRsr1SGB-gj3L9N9qtvqqOh1d-PM4X5rLSgyXxJiTxt2v1K5Ae3xUmn813_YKVN_IPG60OaApUbpD8EFK-oWuMGiTf9YZJmbLsY5TsDCIZEvYg4vVlJTjmIJTbs4oXmdofq4rt8zja09ln-9vndOYRxauf1McXfn-gs5zO9u7k47YSpk651Mx52WXQ68I_-LPh4PdAuQz8czA37XhxZXmOmUMOlRQGHFrXToO3mIZGZ1wGHhmZhZAbXV3Mw0Nt9D-YORLtvC2Jdt6aRLt3Zgr0N74p2gnp_LRa95DstAH8ZFUtEZyfR2Gh1EfPTpcsSK0_LAjV5ndmkKnT3p32FEi8BTINOyaD0YxEj71O6Mm5c09JtLjB9Ceiz_LtdbN9vl-VSzLuMzEuil6wFUx2GmdS2gCvtb1cF-8lGvTpa4WgD2ikZhw5GLSNdMAUB1cavDoTqm6c7aupOGglT8BM0VSonAWn2-Hc-855rdfMeo6ZA64VieZucC0UMAVojDbADN5t31s_QRAMxC1Isg6HveNvow3QcQ6v_YxY80ZKUKxCKFChYa5dvt15W-p41bfibW2DoZjBuZKD-5by_zSkXzzcAnzK-6FgqcQCFWSsoywXRWP6VtWN63qheyPM7Vn9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