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

    <tr>
        <th>Summary</th>
        <td>
            Clang does not recognize portable add-with-carry patterns
        </td>
    </tr>

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

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

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

<pre>
    When writing code for cryptographic primitives, or big integers in general, one often needs to use the ISA's add-with-carry instructions and chain carry flags up a bignum.

Although Clang does provide Clang-specific intrinsics like `__builtin_addc`, they're not portable across compilers. I made several attempts to write a portable add-with-carry here, and Clang seems unable to recognize any of them. Here's a godbolt link with a bunch of them:
https://godbolt.org/z/WTns6M8E6

(CC @andres-erbsen, do you remember if there were other patterns we'd tried?)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx0k0-PpDYQxT-NuZS6Baa7gQOHyWxQ9pBTIu1xZOwCKmtsVGW61fvpI3fPaCeR9mL-uIr3e8-FEaE5IPbq_Js6fynMnpbIvTNXciOGYozu3n9bMMCNKVGYwUaHMEUGy_ctxZnNtpCFjWmlRFcUpV8hMow0A4WEM7IABZgxIBv_2A0IcUoYICA6gRRhF4S0IHz960XpRsA4d7hRWg7WMN-BgiTebaIYBExwYBdDAZ6bkzezwL6ByaJhX4-q_KLKl-f64tMS93mBV2_CDC6iwMbxSg6frw6yoaWJbMZlCkJWwNN3BHUp397GnXyi8Gacs-pSZv604F3phhFCTLBFTmb0CMZyFAEb1408shzhK6zGIQhes3UwKeG6pYfhHCeC-dT9X8cLMmatbPZJLoirwB4e1SkCo41zoB8IJtwhThlrPcIfj8YcIczRjdEn8BS-Q_52TmgPdvmoVvV7SEtKm-QnPSg9vPcdI89KDz-UHr79HeTyZ_v75XOySrevr6BOpQmOUQ7Io2DI0C7CPe7AuOI6IgM95BjhlpeY72HLaXAQuGVcB4kJnaoHpbvC9bXr6s4U2FdNWem2PTdNsfS1baq6O5_r-txMbdM1bdUYPTV1fcHWnUxBvS51XVW602XZ1c1xqi66tdaejRu76jKqU4mrIX_0_rpmgwWJ7Ng3dXtqCm9G9PLxL3Cfiw7jPos6lZ4kyc-2RMlj_2mm8ij8PJJfHeuH62Jn3_8vdUrLPh5tXJUess775bBx_AdtUnp4sIrSwwP33wAAAP__ZYJC8Q">