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.