On Tue, May 8, 2018 at 11:07 AM, Dávid Bolvanský <david.bolvan...@gmail.com> wrote: > Hello, > > Code example: > #include <stdio.h> > > char * a(int e) { > char * s; > switch (e) { > case 0: > s = "0"; > break; > case 1: > s = "1"; > break; > case 2: > s = "2"; > break; > default: > s = "def"; > break; > } > > return s; > } > > > GCC 8.1: > a: > mov eax, OFFSET FLAT:.LC0 > cmp edi, 2 > ja .L1 > mov edi, edi <------ redundant?
Is a zero extend from edi to rdi. Yes it is written as a mov but it causes the cleaning of the top 32bits of rdi. Thanks, Andrew PS gcc-bugs@ is really for the automated bugzilla emails so sending it to gcc-bugs@ might not get that much attention. > mov rax, QWORD PTR CSWTCH.0[0+rdi*8] > .L1: > ret<div id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br /> <table style="border-top: 1px solid #D3D4DE;"> <tr> <td style="width: 55px; padding-top: 13px;"><a href="http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail" target="_blank"><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-green-avg-v1.png" alt="" width="46" height="29" style="width: 46px; height: 29px;" /></a></td> <td style="width: 470px; padding-top: 12px; color: #41424e; font-size: 13px; font-family: Arial, Helvetica, sans-serif; line-height: 18px;">Virus-free. <a href="http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail" target="_blank" style="color: #4453ea;">www.avg.com</a> </td> </tr> </table><a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"></a></div>