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

    <tr>
        <th>Summary</th>
        <td>
            LSR dropping nneg flag on zext in loop preheader
        </td>
    </tr>

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

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

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

<pre>
    When induction variables have been widened, the loop preheader often contains something like `%wide.trip.count = zext nneg %x`. If LSR changes the loop, the nneg attribute appears to get lost.

RISC-V now depends on the nneg flag to form ISD::SIGN_EXTEND in SelectionDAGBuilder instead of converting zext to sext in RISCVCodeGenPrepare::visitZExtInst so the loss of this flag hurts RISC-V.

I'll work on extracting a reproducer.

cc: @preames @nikic 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxcksFu2zwQhJ-GuiwiUJQl_z7o4MRxYOBHUMRFWvRSUORaYkOTBLmy3T59QTmtkV5EAdLOzMcdmZIZHGLHmnvWbAo50ehjRz4EjKrovf7ZfRnRgXF6UmS8g5OMRvYWE4zyhNAjOjgbjQ41Ew9AI4L1PkCIOKLUGMEfCB0o70galyD5I9Jo3ADWvCGwljPRZIWSogml8pMjYPUGfuGFwDkcgInmwlpewu4A_-9fQI3SDZj-mv0xnn-WRNH0EyHIEFDGBORhQALrE5WMbxhfX58vu_3D3Ss4fwaNAZ1O4N1N6GDlkGcPPh5ht9-wes3q9X739Pz98evnx-cNGAd7tDhfzGb9dD8Zm4GNS4RSgz9k6hNGyrQzDnlI-TQOsvvrg9f4hO5TxCAjXh1OJhn69nihnUsEyb9jppQFaTTpmmycIiW4MnzA2jGxtBbOPr5lHrxQlGqOICFiiF5PCuOHEaVYvQa24CGiPGLKr868GQWF7mq9qleywK5qVysu_msEL8ZOCVRc4KFfykYrrgVWbdtUQvRyVddKFqYTXNRVxeuqFYLzsu8XWPMWxbLXFVecLTgepbGltadj6eNQmJQm7JaV4Lywskeb5mIK4fAM80cmRO5p7PLMXT8NiS24NYnSTYUMWexyT3T0IWTw2z69uy7CuH9qWkzRdiNRSHkLYsvEdjA0Tn2p_JGJbZZ_P-5C9D9QERPbOVRiYjuH_h0AAP__zqUYfQ">