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

    <tr>
        <th>Summary</th>
        <td>
            flang/LoongArch "Do not know how to promote this operator" in DAG->DAG Pattern Instruction Selection
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          martin-frbg
      </td>
    </tr>
</table>

<pre>
    Compiling the LAPACK parts of OpenBLAS on a Loongson 3A6000 running Debian sid currently fails with both 18.1.8 and 19.1.0
producing the following error messages. (This should also be reproducible with Reference-LAPACK from which these parts are copied verbatim, if you prefer to test with a project that is entirely in Fortran)

```
flang-new-18 -O2 -march=loongarch64 -fPIC -c -o slacon.o slacon.f
flang-new-18 -O2 -march=loongarch64 -fPIC -c -o slacn2.o slacn2.f
LLVM ERROR: Do not know how to promote this operator!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /usr/lib/llvm-18/bin/flang-new -fc1 -triple loongarch64-unknown-linux-gnu -emit-obj -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -target-cpu loongarch64 -mframe-pointer=none -O2 -o slacon.o -x f95-cpp-input slacon.f
1.      Running pass 'Function Pass Manager' on module 'FIRModule'.
2.      Running pass 'LoongArch DAG->DAG Pattern Instruction Selection' on function '@slacon_'
LLVM ERROR: Do not know how to promote this operator!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /usr/lib/llvm-18/bin/flang-new -fc1 -triple loongarch64-unknown-linux-gnu -emit-obj -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -target-cpu loongarch64 -mframe-pointer=none -O2 -o slacn2.o -x f95-cpp-input slacn2.f
1.      Running pass 'Function Pass Manager' on module 'FIRModule'.
2.      Running pass 'LoongArch DAG->DAG Pattern Instruction Selection' on function '@slacn2_'
```

Diagnostic output attached, this was originally reported in https://github.com/OpenMathLib/OpenBLAS/issues/4907
slacon.f is at https://github.com/Reference-LAPACK/lapack/tree/master/SRC/slacon.f
[slacon-dda0eb.zip](https://github.com/user-attachments/files/17245082/slacon-dda0eb.zip)

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzslk1v2zgTxz8NfRlQoCg7tg4-uHFUFI-DBs6DvS4oaiSxoUiBL3Gzn35BSU7SoiiK3VOBBQyZJMQZzp-_mZHwXnUGcU82H8jmuBIx9NbtB-GCMrR1dbeqbfOyv7XDqLQyHYQe4XR4ONz-D0bhggfbwucRzYfT4RGsAQEna03nrYHicMMYAxeNSTuPWCthwKsGZHQOTdAv0AqlPVxU6KG2oYd8l-XZDoRpIC-zPGOEHQk7jM42UV79t1Zre0kzdM46GNB70aHPgPDd_3vlwfc26gaE9hZqBIeLgVrj7OyMLTo0EukSTOvsAJdeyT658LhEJxyCtKPCBp7R1SKogfBbUC282AijS2YgWAjow2xZwOjsF5QBQi8CKA9ognKoX0AZqKwLThjCyzmw5XnDlt80bbUwHTV4ofkO6GcOdBBO9qQ46qRtGt-sgbYPn26BSqAWvBbSmux10P4bQ4Znr4PF0On0xz3cnc-fz6Q4wNGCsQGejL1Aby8p_tHZwQaEkNS3IzoRrCM8n7c_nO4Oj3fgYz2oAALq2KU7sS6kvX0IoyfFgfCK8KpToY91Ju1AeKX18_WPLrISXinvI3rCq4kTZaSODU5kSCd8D7WQT8EJidns_jEI-QRNHMbkZVpiGWHlg7OdEwMI18UBTUiHAMKr6F1yquqr63xHeFUrQ3j1KinQVuZAg1OjRninJ40mKWOoViZ-pZ2JQHFQgdr6S9pktXW0UaIz1gclPdDBobZSBGUNHWyDGkYlgY5KUo3PqIEDDcJ1GKgcI3xzd0PrxIB0tMoEdKQ4Gmtwvut3WNCv0JYbKseRKjPG8B0neVLjvOTpKLwHwrdVNDIdCR7Swr0wokN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