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

            Bug ID: 110087
           Summary: Missing if conversion
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ubizjak at gmail dot com
  Target Milestone: ---

Following testcase:

--cut here--
#include <stdbool.h>

_Bool foo (void);

_Bool bar (_Bool r)
{
  if (foo ())
    r = true;

  return r;
}
--cut here--

compiles for x86_64 target (-O2) to:

        movl    %edi, %ebx
        call    foo
        testb   %al, %al
        cmove   %ebx, %eax

More optimal code would be:

        movl    %edi, %ebx
        call    foo
        orb     %bl, %al

Reply via email to