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

    <tr>
        <th>Summary</th>
        <td>
            CodeGen X86: f16c implies all of AVX instead of just XSAVE
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            backend:X86,
            llvm:codegen
      </td>
    </tr>

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

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

<pre>
    Alright - up top I am just going to say that when it comes to the codegen underbelly I am not sure I know exactly what I am doing, but we noticed something when porting a project from MSVC to Clang.

This project uses some F16C intrinsics, specifically `_mm_cvtph_ps`.

If we enable `-mf16c` in Clang that implies that all of AVX gets enabled as well. This can be seen in the code here: https://github.com/llvm/llvm-project/blob/main/llvm/lib/Support/X86TargetParser.cpp#L541 - which in our case is undesirable.

But reading around on internet it seems like it only requires `XSAVE` - which has it's own `FeatureXSAVE` flag. So I wonder if there is a reason to enable all of AVX in order to use F16C or if we could change it to `constexpr FeatureBitset ImpliedFeaturesF16C = FeatureXSAVE;`

I tried this change locally and the test-suite passes, and I could compile a small test program using `mm_cvtph_ps()` and see that AVX is not enabled, but since this is pretty far outside my expertise I want to make sure I understand that I understood it correctly.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVVE1v4zgM_TXOhWiQyIknOfiQpttFgV1ggQ6K3grZpm1NZckrypPJv19SdjvNcYGiDvVBPj6-p8o31_Jkg-n6CHcwjRD9CE-gB_gxUYTOG9fxGpC-Qux1hEuPDkyE2g9IshN75KDBjtcn12Co0NrrnMP5CDQF5Ojd-QvgL11H3rxIpnSikQKZOkM1cW6UG6bGBojTx16Kp4KjD1ECDWPwP7CO0AY_wN_PL2fBcLbadets85BtTvP_772hz7MTMVTJCI_b4gzGxWAcmZqkMI1Ym9bUWlBnxeZtGN7qn3Hs30bi8CbrUysY0enKopy9G9ptUfMPz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