This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug rtl-optimization/46265] New: Missing ifcvt


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

           Summary: Missing ifcvt
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: xinliangli@gmail.com


Compile the following code with -O2

int *gp;
int g, g2;
int foo(int p)
{
   int t = 0;
   if (p)
      t = *gp + 1;       

   return (*gp + t);
}


Trunk gcc produces:


    movq    gp(%rip), %rax
    xorl    %edx, %edx
    movl    (%rax), %eax
    testl    %edi, %edi
    je    .L3
    leal    1(%rax), %edx
.L3:
    addl    %edx, %eax
    ret


llvm (with clang) produces:


    movq    gp(%rip), %rax
    movl    (%rax), %ecx
    leal    1(%rcx), %edx
    testl    %edi, %edi
    movl    $0, %eax
    cmovnel    %edx, %eax
    addl    %ecx, %eax
    ret


Gcc's ifcvt seems weak. If changing t=*gp + 1 to t = g then the assignment can
be ifcvted by gcc.

David


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]