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

    <tr>
        <th>Summary</th>
        <td>
            SimplifyDemandedBits should handle fneg/fabs/fcopysign
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            good first issue,
            floating-point,
            llvm:SelectionDAG
      </td>
    </tr>

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

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

<pre>
    fneg, fabs and fcopysign are defined as bit operations, and should be subject to bitwise simplification. Fneg is xor with a signbit mask, fabs is and with a sign mask, and fcopysign is and signbit mask, and inverted signbit mask, and or.

This would allow deleting [more specific optimizations in visitFCOPYSIGN](https://github.com/llvm/llvm-project/blob/5ee53d417f41e8f452255ded1ff6a522afe17f08/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp#L17552) 

This was brought up in https://github.com/llvm/llvm-project/pull/97180#discussion_r1660844076_

Attaching starter patch to point where this needs to go:
[0001-TODO-Support-FABS-FCOPYSIGN-FNEG-in-SimplifyDemanded.patch](https://github.com/user-attachments/files/16070829/0001-TODO-Support-FABS-FCOPYSIGN-FNEG-in-SimplifyDemanded.patch)

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVE2P5CYQ_TX0BbmFy8YfBx96uuNWpGgnUu8lpxU2hU2CwQI8ncmvj3BnJrObSNEqFyNBfbxX9fxECHqyiB3hT4RfDmKLs_Od8AHtchicfO2UxYnAmSoxBCqspGp062tKo8Ijlai0RUlFoIOO1K3oRdTOhpSTwsPsNiPpgDRsw684RhpdCr3rgDToZTVa6XHPOdLe4kR1oL87T-86zlTQ1ClVXkT47R2HfkD5EPL-_jXEvwK_LZLutH1BH_HfH50_EnYh7PT4fp51oPediDDG3alEg1HbiRL-tDiPNKw4JiLUrVEv-o_HEKi29EUHHfvz88-_3H68fiL8QqCZY1wDKU4EegL9pOO8DcfRLQR6Y17ejmz1Lk2MQD8YNxDoOSIvZJnXqsyxUSUH4FyizJWqBAcQCvNaseZDHZ3yzk7iFS2B_oYGx4TtcroS6C-n69ktg7boj-O6Eih-ymvOgUBL_zmAtGTvtmmOdFsTt-_msW7GEOjbOm8YgULqMG4haGe_-LyqWFOWrK6-fOx8ilGMcxp1iMJH9HQVcZyTilanbaT3GT3SmABaRBnSy-QSqEcV_sQYy7PPz5fn7Latq_Mx609Pt-x9J1n_6Ydrpm12e8jx9YKLsBLlcW_1nyvbAvpM7DgXtDEQ6JU2mM68YjVroCXQ_18U0D4IHWRXyLZoxQG7vM7btijLqj7MnWpQ1SNTQrXIUDaqGivWtIPAUiheVgfdAYOS1QxyXpRQHxFYw3ldQ80Z5CwnJcNFaHNMWzs6Px10CBt2bV1CfTBiQBN2qwCYnJNUaR8i3WMIAIEzAVDGifRnZPt23q93ORSnr-UHyXN8t2tk2KZASmZ0iOHv_lFHg923E3nSMbwZyyysNEgfNtUnd0jHmwEcNm-671bpzijsOk3EXzr4MwAA__9rfq42">