<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=http://email.email.llvm.org/c/eJylVNuOmzAQ_Rp4GSUy5rLwwEMuilRV_QiDJ-DK2BSbbbZf3zFJGrHdRisVWQyeI2aOzxlorHyrD3YYxYQSvIWubSN-gFYL08E4WTm36MBp1fVev8FgJ4RXnBrrEForEc52AgEOf8xoWozYMWK7271gt7VslfHg0fkk4mV4FhGvIHrZw4R-ngwVidITbBIKO0iidE_g8foq3K4L9QoXiksgGcIKD-UXXKoFp7DCHXoMUeh1Xkj5tO47fJOsYTrAhye-3nen3Zev4TXfI9jRq0HoP3qBck8kM9g9DuGa5i-CpMctlTxh8LNXbU9uzVpCg0B9yTgJ58kOT51in3GKfehUYH53Ym0BneKZ1A8t10PT_IPLnectf3g3OR874sLEKhpeYz0GGjT10ApzH_jFKryM2HrSyc5-nP0iF1ClG52CQUNZqrBGKG6vbWJZp7JKKxGL2fd2qmfTahRuiOdJ1733oyMBI36i1Snfz822JUf4SevXe9gQo-9Eg7bKuRkdPeQpY0Xc11mZcVEUFStLXpWsKDKRCZblWZpyLlIZa9GgdnWU76P8GP9_S1VzxjlLWJ5kacn5luXZC08rLFshRXquoozhIJTehjpbO3XxVC8lm7lzBGrlvHuAwjnVGcQ7Q6-8xvobdQ2qhy9F_RJeWeNAGZpfI1XYCU0_Iof66g6lnRfGu3hhWy9UfwNYV2N7>53006</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Missed optimizations in conditionally selected constants
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

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

<pre>
    Compared to gcc, clang produces slightly more verbose code for a sequence

```
int test1(int a) { return a ? -1 : 1; }
        xor     eax, eax
        test    edi, edi
        sete    al
        add     eax, eax
        add     eax, -1
        ret
```

AFAIK, the optimal sequence is

```
neg edi
sbb eax, eax
or eax, 1
```

which could be encoded from
```
int test0(int a) { return a ? -1 : 0; }
        neg     edi
        sbb     eax, eax
        ret

int test1b(int a) { return test0(a) | 1; }
```

As a side note, gcc can produce the expected output from `test1b` but not from `test1`.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyNU12vmzAM_TXwYrUKofSWBx76oUrTtB-REAOZQsJIuOvdr59D21XcddWiCCc-in3sY6RTH9XR9YMYUUFw0NZ1wo9QG2FbGEanpho9eKPbLpgP6N2I8I6jdB6hdgqhcSMI8PhjQltjwk4J29--W3bb81XbAAF9yBK-i2eR8BKStwOMGKbRUpAkP8MqI7OHLMkPBJ6uT-G2LpQrLhSXSDKaBR7Dz7jSM05mgXsMGK0wS79Q6mXcT_gqW8JUwNOKr9_9ef_la3wWOgQ3BN0L86dfoP2LlllsH0V4Kf8iSP24ubIXDH52uu5IrckokAiUl4RT0Iyuf6kU-x-l2FOlIvO7EksJqIpXrX70cjk08h9c7jxv_uOnyXmuiI8Tq2l4rQsYadDUQy3sfeBnqfAyYB2oT24KwxTmdgFFutHZMpDkpQhLhOz6miZVVa7KvBRp0MFg9U17H8PFEdC_RNDOetCWhLFKx5sw9Id5NNe05PZB2ODTaTRVF8Lgqd8JP9Nudegmua5JQH425v1uVlTAd3pOV0o2oadDkTO2TbsKmcrKrWiY2JWNZFw1YsexlA3fNAVv8tQIicZXSXFIilOqK844Zxkrsk2-43zNis0bz0vc1UKJvCmTDcNeaLOOiddubNOxmjnIqfUEGu2Df4DCe91axHt8MYXOjdVka4PC9-nMt5rJ_gbIqU_x">