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

    <tr>
        <th>Summary</th>
        <td>
            Simple function integer return corrupted.
        </td>
    </tr>

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

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

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

<pre>
    I stumbled upon a quirky little bug which I can not identify. A simple C program with C11, compiling in XCode. I use the following setup:
Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: arm64-apple-darwin23.5.0
Thread model: posi

The following computes twice the same value. Please do not bother about how and why I do this.
```
int testGetSignum32(int i) {
  return (i >> (32 - 1));
}
int testAbsi(int i) {
  int signum = testGetSignum32(i);
  return (signum ^ i) - signum;
}
int main(int argc, const char** argv) {
  int myVar = 0x80000000;
  int signum = testGetSignum32(myVar);
  printf("%x, %x\n", testAbsi(myVar), (signum ^ myVar) - signum);
  return 0;
}
```
When running with optimized code generation, The result is `1c60, ffffffff`. But the two results should be the same.

Funnily, if I add another value to the output, it changes. For example:
```
  printf("%x, %x, %x\n", testAbsi(myVar), (signum ^ myVar) - signum, 0);
```
results in `6fdff2f0, 80000000, 0`

And if I switch places of the two arguments of the original line, I get `80000000, 47a0a0`

MSVC has no problems with that piece of code.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVUGPqzYQ_jXOZRRkDCThwCEvu6lyeFKlrV57NTCAW2NTe7zZ9NdXdrK76PWpvRRFIrJnvu-bmc9Geq9Gg9iw6gurnjYy0GRd81WaHl1727S2vzUX8BTmVmMPYbEGJPwZlPvjBloRaYQ2jHCdVDfBBTppwFgC1aMhNdwyOIJX86IRTrA4Ozo5w1XRBKc8Z-IEnZ0XpZUZQRn47WR7zOACwSPQhDBYre017nqksLDiyPjxuES4Tkszwis6r6yBvMp4xoGJQ1rf5hXnWZ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