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

    <tr>
        <th>Summary</th>
        <td>
            [HLSL] implement `sqrt` intrinsic
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            backend:DirectX,
            HLSL
      </td>
    </tr>

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

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

<pre>
    The current sqrt intrinsic is incomplete  in some cases and not correct in others.

For example there is no `double`  support.  Doubles need to cast down to floats:
https://godbolt.org/z/Pc73srEr7
Yet we added it here: https://github.com/llvm/llvm-project/blob/main/clang/lib/Headers/hlsl/hlsl_intrinsics.h#L1421

Second we should be using `__builtin_elementwise_sqrt` and not multiple different builtins especially since all sqrt builtins map to the same `Intrinsic::sqrt`
https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CGBuiltin.cpp#L2908

Using one builtin makes it easier to apply type check rules in sema.

Finally lowering support needs to be added. Sqrt lowering is very simple and has a one to one mapping between

`Intrinsic::sqrt` and  dx.op.unary 24
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyklEFv4zYQhX8NdRlUkCjJsg86ZONqt0AOBdIC7cmgyLHFhiJVDrVe59cXo8hpWrSHohcTosk3w-89UhHZi0fsRPNJSHlW8TV4J6QUzTFTSxpD7LbJbAjm1v00IuglRvQJ6PeYwPoUrSerwRJYr8M0O0wIYD1QmBC0IiRQ3oAPCXSIETVvg5BGjJSL4iiKh7ffPkTAb4olgP9FFvUBxK4wYRkcil0BQMs8h5hygOM6SeARDaTAtRKYcPX8cXZBJRLVpj2mNK9fsheyvwQzBJfyEC9C9q9C9j_qtqL4fWzflv-KCa4Iyhg0YBNwN6J6gL_J2DQuQ67DJGTv3Nf78N0cw2-ok5D94MIgZD8p64XstVOeKzrLk19QGYwkZD86cttwekdK-Shk9VTWsvxI6Rl18Ia7ozEszsCAsJD1F-Z0Og2Ldcn6Ezqc0KerJTyxVczubsO0uGSZsrHnM65ubtsIkGbUVjl3A7JeIyjn3rx-XzKpmQmnEYHUhFz3h3vTzKZ62Ar-I_r_x-wxGPyMPP_4-dNbQ7meZwYlD8X-I6ifVyjB471zmNQLEtuJiixGPoSaZ3eDdJsR9Ij6BeLCkeL44qT-Gk_rVywuXDGy9JbENX_EYsOWmByeGdj7QkvwFSMDXbPNNoyKQK3NpbAOk5pnXjtguiL6j4X_le-qBOZbHuZ88SreQNaZ6SpzqA4qw65sy7KoD_umzsbOmLIoGql1O-i2rYq2rIazVO15aFS7a9rMdrKQdVHJsjxUbVXnpm7M7iwbiaXE_aEUdYGTsi5nv_juZJZowW6_K_dt5tSAjranZFD6Bb0R1cPR8o3_hR8V-Sik_PL0_LS9MLFbjR-WC4m6cJYS_SmdbHLrw7RuaI6wsuNIc97uAN4vS7ZE1_3npK398wVcj_BHAAAA___9eqqd">