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

    <tr>
        <th>Summary</th>
        <td>
            clang does not add !fpmath data to OpenCL sqrt calls
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:codegen,
            OpenCL,
            missed-optimization,
            floating-point
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
            svenvh,
            yxsamliu,
            AnastasiaStulova
      </td>
    </tr>

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

<pre>
    By default (i.e. without  -cl-fp32-correctly-rounded-divide-sqrt), calls to float/vector of float sqrt should be annotated with !fpmath metadata. Currently they are not which is interfering with fixing the library from using a global option corresponding to the flag.

I tried working towards this in bac2a075408377a8aa41f6626b17bb3e471221f3, but this is of limited use for the end use case. The actual user call to the mangled function needs to be annotated (such that a backend pass can swap out the call to the intrinsic with presered metadata) so we can lower it appropriately.

I'm not sure how to really do this. I tried hacking up LANGBUILTINs for all the mangled forms, but they don't seem to be recognized as builtins at that point for interception in CGBuiltin. Another strategy I considered was adding a macro for the correctly rounded option and setting an attribute on the declarations?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxUlM2SmzgQx59GvnTZBcKx8YGDZ1JOTVUqe9jsAzRSA9oIiVU3dpyn30J4nMzFBtGfv279kdn1gahRn16U1nylcB2U1kq_Kq3vPxlH7-bnwTkgC7LDv2X28YrLh0-fNzjLEFODiSmMmzbae_NyB0sdzl5A6drtaAc3J0OcBWBr_LabKr01MSUy4u_bFOdgyW6tuzpLW_4vidInpV_BoPcMEqHzEUXpy5WMxASxW09gsQUe4uwttAQYQhQUsjkfKF1204gywEiCFgV38DqnREH8HWSgO2AiCFHgNjgzgGNwQSh1lFzo1yCd-7k8y0DgXZsw3aFLcYSZl2OE3scWPcRJXAyQu-IpBpudYvbrPPY7VXxWxXn9fQNJbqkyph-r3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