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

    <tr>
        <th>Summary</th>
        <td>
            HIP compilation fails from undeclared identifier
        </td>
    </tr>

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

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

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

<pre>
    On a recent mainline build, a HIP program including a thrust file fails with an error about an undeclared identifier:
```
/opt/rocm-5.4.3/include/hip/amd_detail/amd_hip_fp16.h:1520:21: error: use of undeclared identifier '__llvm_amdgcn_rcp_f16'
 1520 | __llvm_amdgcn_rcp_f16(static_cast<__half_raw>(x).data)};
 | ^
/opt/rocm-5.4.3/include/hip/amd_detail/amd_hip_fp16.h:1623:47: error: use of undeclared identifier '__llvm_amdgcn_rcp_2f16'
 1623 | __half2 h2rcp(__half2 x) { return __llvm_amdgcn_rcp_2f16(x); }
      | ^

```


The reproducer (the problem is in hip_f16.h, which gets included from thrust):
```
#include "hip/hip_fp16.h"
//#include "thrust/sort.h"

int main()
{
}

```

Compile line: `clang++ -x hip -I /opt/rocm-5.4.3/include hip_test.cpp`

The test uses rocm 5.4.3, but it also reproduces with rocm 5.5.0.

This affects mainline builds.  I don't know when it started, but a mainline build from May does not show this issue.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVE-PpLYT_TTFpdQIbP71gUP_2dZvDj8lh9yRsQ04a2xkm_Tut48MTHZmNJsckhaisex6Ve_VczHv1WikbKG8QnlP2Bom69qZua9CPpUZk96K7-0vBhk6yaUJODNltDIS-1VpAeSGDP_38isuzo6OzagM16tQZkSGYXKrDzgoLXFgSnt8qjAhMyidsw5Zb9cQl6sRkmvmpEAlpAlqUNIBvUB2h-wCVXY8-5I87BKAPJzl86lMi5QCeex5JZDHpBYgDzaLTsjAlD4Wk1q6YcmrdAJ6yUuSAb2QHOhlLyZ-rF6iHT6vBoHUXaf1H3PHZjFy0zm-dENeAan3ujCCItQ3_Mm5xgcWFO848wHoresmpofOsSfQL0Cab0DOqWCBATlDfQd6PXAjJJRf_kP2FaFAL0X9L9mT9_QrQg_6kRjBiTi-AGle15EgQn1FJ8PqzCcy7YCbEkCvGFXYsbffex0-tcab92-TRCcXZ8XKNwJNmGS0aa_ljMqjMripsolCbvicFJ9wlMEfJpYCB2fnw8ZbTT9zJD0iEAjZO_BGcEL-at32vD38iv3w1oW3Z7e3Oi4ckCam33fq6-vH_R-luNl5ibcv3tjYY6gyrpkZgVyBXPH0LUqApxf8W1ttOgXpQ8qX5UOGKHPcivbxGKPxiL5hvwZUAZn29kcrjiFwnCzTLH0PpzyyYZA8-A-zxqeILyisAVIH_GrsE5-TNDGDD8wFKV5zsg-Rexv_z76jsNKjsQH9ZJ8YYjLl_SqPGhLRUnGmZ5bINq-ac1NVRV4nU5sVeT30dcMlLYqKMNFUWVOzqmgyysu8SlRLMkKzmmRxCuR12lSU9EVRNEPe9wMvocjkzJROo-dT68ZkS9xW9NzkiWa91H4bw4QY-dyrim4o74lrY8ypX0cPRaaVD_4HSlBByzZOYL71mgVlzTFtN9qf3udkdbqdQlh89PTmy1GFae1Tbmcgjwh__J0WZ3-XPHpjK8oDeWxF_xkAAP__1Mjqyw">