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

    <tr>
        <th>Summary</th>
        <td>
            WASM: Add choice of selected instruction, and subsequent missed optimization
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          matthias-blume
      </td>
    </tr>
</table>

<pre>
    Instruction selection for WASM takes "advantage" of knowledge of byte alignment properties of the __stack_pointer global and prefers "or" instructions over "and" when it can.  But the resulting code suffers from the fact that subsequent optimizations are unable to combine such "or" instructions with other additive operations, resulting in more instructions than necessary.

Example:

https://godbolt.org/z/afvf5bvP3
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx0Uk2PnDoQ_DXm0toRa2AGDhxm3z6kd3hSpBxyXLVxA84am9jtmez--shMpJ2NlANfXbiqurswRjM7ol40T6J5LjDx4kO_IvNiMD4om1YqlNdv_X8uckgjG-8gkqXb2-QDfDt__R8YXymCkBL1BR3jTEJK8BO8On-1pGfKH-qNCdCa2a3kGLbgNwpsKGaQF4KXl8g4vr5s3jimALP1Ci2g07AFmijsGj5kcvPhKIK_UNjlnc7YdSEHhmFEdwB4SryzB4rJsnEzjF4TxDTtjFPw645POOYfkSEmFelHyib9xmY173jTwUCQHCpLwB5GvyrjMtO4_MXY1fACnhcKgFobNheC3PWNT8h_7lwZB6sP9JmAF3TgaKQYMbwdRPksyvPt_u9PXDdLojrfVxfmLeaaHIQcZq-Vt3zwYRZyeBdywOkyNerypSp0X-mu6rCg_vHYteXpVLWyWPq6pZHo2Mima7Cuu3o6nY4oJ6pb-SgrVZhelrJ6zNex7Kr2UKoO24aUrjrSXVuLuqQVjT1Ye1mzdmFiTNQfu65qC4uKbNxDJ6WjK-ygkDJnMPT5zINKcxR1aU3k-MHChi31OXGiOsNZaxgXb8Y9XLdUkr4fX55vDs_dPlcTI-lPay1SsP0fYzO8JHUY_SrkkOV_Px624L_TyEIOu-ko5LA39SsAAP__NskfYg">