https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97397

            Bug ID: 97397
           Summary: Unnecessary mov instruction
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: drepper.fsp+rhbz at gmail dot com
  Target Milestone: ---

This simple code

const char s[][3] = { "aa", "bb", "cc", "dd", "ee" };

unsigned f(unsigned x)
{
  return s[x][1];
}


translates with gcc 10.1 and the current 11.0 trunk version to

   0:   89 ff                   mov    %edi,%edi
   2:   0f be 84 7f 00 00 00    movsbl 0x0(%rdi,%rdi,2),%eax
   9:   00 
   a:   c3                      retq   


Obviously, the initial mov instruction is completely unnecessary.
  • [Bug target/97397] New: Unn... drepper.fsp+rhbz at gmail dot com via Gcc-bugs

Reply via email to