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

            Bug ID: 110811
           Summary: under-optimized code for x86_64
           Product: gcc
           Version: 13.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lixinyu20s at ict dot ac.cn
  Target Milestone: ---

The following example is not properly optimized, resulting in low quality code:

long a;
int b;
void foo(int c) {
    int t = c > 0;
    b += t;
    a += t;
}

Compile command: gcc -O3 foo.c -S

Output:
foo:
        testl   %edi, %edi
        setg    %al
        setg    %dl
        movzbl  %dl, %edx
        movzbl  %al, %eax
        addl    %edx, b(%rip)
        addq    %rax, a(%rip)
        ret

There are redundant setg and movzbl.

Reply via email to