[Bug c/89954] New: missed optimization for signed extension for x86-64

ntysdd at qq dot com gcc-bugzilla@gcc.gnu.org
Thu Apr 4 01:31:00 GMT 2019


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

            Bug ID: 89954
           Summary: missed optimization for signed extension for x86-64
           Product: gcc
           Version: 8.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ntysdd at qq dot com
  Target Milestone: ---

This code snippet 

/////////////////////
char c;
int f()
{
    return c ^ 1;
}
/////////////////////

is compiled into these instructions with options "-O2 -S"


;;;;;;;;;;;;;;;;;;;;;
        movq    _c@GOTPCREL(%rip), %rax
        movzbl  (%rax), %eax
        xorl    $1, %eax
        movsbl  %al, %eax
;;;;;;;;;;;;;;;;;;;;;

Only movsbl is needed because xor by 1 doesn't change high bits.


More information about the Gcc-bugs mailing list