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

    <tr>
        <th>Summary</th>
        <td>
            undefined behavior sanitizer check for `bsr `
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            enhancement,
            compiler-rt:ubsan
      </td>
    </tr>

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

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

<pre>
    the following code has undefined behavior
```
static inline long bsr_long(long word) {
  long result;
  __asm__("bsrq %1, %0" : "=r"(result) : "r"(word));
  return static_cast<long>(result);
}


int main() {
    return bsr_long(0);
}
```

https://godbolt.org/z/39rfj6ceM

since `bsr` is undefined for 0 input

It would be nice if a check could be added for this.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxsUtGO4yoM_RrnBU1FTEKbhzx0pjfSfdhvqAg4DbMEukCm2vn6VdLsTGd3JYQB42P7HKuU7MUTtVA_Q30q1JzHENvbSCpPyhd9MD_bPBIbgnPhZv2F6WCIjSqx2RsarCfDehrVmw0R-An4ESTf1npNWWWrmfXOemIu-AvrUzwvB8DDer-FaAAbBvvnewy7_4uUZpdBfLyezypN5zPgARD7FH8wwLoEfFksB0QG4sgAEcQpLgYPG8aCfndt71vOZX3iR8pz9Oxe8lmrlEG8rJWK_x6xPkJgf9oOD7v1mU3K-rXML119ZHhggP8b7yuJ933M-ZpAHAE7wO4STB9c3oV4AezeATvRxOFVavr2GJSs18RA8j5FkJzZR-WGEBln1l_n_Bjzf2a3MLtFWeatJmYHppgeSX9n-rdDGbMh5NGmXWFaYRrRqILaUjYHUR14JYuxJcn7ZhB1KXstzaDLSvLyUA49L_eDGExhW-QoSo6ybJBXcodYq6qWjUJTyVJqqDhNyrqdc2_T0m9hU5qp3XOx54VTPbm0TjAi-VF5TRP5vOr8Aog6TFfrKD7FDOI490n5xVefitguiE_9fElQcWdTTp85ss2O2r-nnCXlbbbvFDdGFgru_C6mmKNr_1DK5nHudzpMgN2Cv5mnawyvpDNgtzaUALu1p18BAAD__3ikE44">