https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88676
Bug ID: 88676 Summary: missed opportunity is integer conditional Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: drepper.fsp+rhbz at gmail dot com Target Milestone: --- Take the following code: int f(unsigned b) { int r; if (b >= 2) __builtin_unreachable(); switch (b) { case 0: r = 1; break; case 1: r = 2; break; default: r = 0; break; } return r; } Compiled using the current trunk gcc and gcc 8.2.1 with -O3 on x86_64 the following code is produced: 0000000000000000 <f>: 0: 31 c0 xor %eax,%eax 2: 83 ff 01 cmp $0x1,%edi 5: 0f 94 c0 sete %al 8: ff c0 inc %eax a: c3 retq This is quite good but it should be something like leal 1(%edi),%eax ret The first three instructions test for 0 or 1 and load into %eax the values 0 or 1 respectively. This should be just a move.