Consider:

int
foo (int a)
{
  switch (a)
    {
    case 1:
    case 3:
    case 5:
      return 1;
    default:
      return 0;
    }
}

./cc1 -O2 -fomit-frame-pointer -mregparm=3 -march=athlon-xp generates

foo:
        cmpl    $5, %eax
        movl    %eax, %ecx
        ja      .L2
        movl    $1, %eax
        movl    $1, %edx
        sall    %cl, %eax
        testb   $42, %al
        jne     .L4
.L2:
        xorl    %edx, %edx
.L4:
        movl    %edx, %eax
        ret

Note that if-conversion is not performed at the end of this function.

-- 
           Summary: if-conversion is not performed for some reason
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P2
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kazu at cs dot umass dot edu
                CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18146

Reply via email to