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

    <tr>
        <th>Summary</th>
        <td>
            [DAG] SimplifyDemandedBits/SimplifyDemandedVectorElts - improve handling of multiple uses of MemSDNode chain
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            missed-optimization,
            llvm:SelectionDAG
      </td>
    </tr>

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

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

<pre>
    When calling both SimplifyDemandedBits/SimplifyDemandedVectorElts, we check if the entire node has multiple uses and then set the demandedbits/elts to ALL if it does.

But for memory loads (inc. MemIntrinsicSDNode) this behaves poorly with cases if all but one of the uses are for the memory chain - we should still be able to create a new MemSDNode (with adjusted memory width etc.) if we only use the loaded result once, as long as users of the chain are updated afterward.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUk8GO2zwMhJ9GvhAxbCVOnIMP2c2fH0W3PTRAe5YlOuJWlgyJTpA-fSFnFy321pMAkeJ8HI9VSnTxiJ1onkRzLNTMNsTu2-czjcEXfTD37odFD1o5R_4CfWALZxonR8P9iKPyBs0TcRLy9PH6O2oO8T-Xi89wQ9AW9U-gAdgioGeKCD4YBKsSjLNjmhzCnDCB8iZ3eUjIS7t5G9o_tNBxAg5weHnJA4nBBEylqA6iOjzNDEOIMOIY4h1cUCaBkC15XcIXHD95juQT6fPxazAo5B7YUoIerbpigimE6O5wI7agVcahAZRz0M8MwSOExwoP0oiLWL54E9RWkYdVXjnZMDsDiSk_R1C9w8ytIypGUODxlpEeJBlyUVXmdU6M5n3ijQxbQNZlhqUhjw7e3TPCopx3RAMR0-wyo8bsuUrggr_kc04Y0zv4AzCTz5NRWUcNjPGmoikL063Nfr1XBXb1br2Xe1nLtrBdX2O92wx13Va7eivrpsV22Ji23uEa22FfUCcr2VSyruvtRlZtOayHut-YXvey2cu2EZsKR0WudO46liFeCkppxq6W2912UzjVo0tLFKUcKSU0qzAxjfRLMQUvpBTyWUiZn4v14YwOdS4cD__nWnMsYpdrq36-JLGpHCVOf8SY2C1Jz_3N8d9jDCugcYrhmhPrzfJDhOFDcsPw1_dcjC7m6DrLPCWxPgh5EvJ0IbZzX-owCnla1nkcqymGV9Qs5GmxJvO8uXPt5O8AAAD__3J7QWQ">