public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/46265] New: Missing ifcvt
@ 2010-11-02  0:37 xinliangli at gmail dot com
  2010-11-02 10:24 ` [Bug rtl-optimization/46265] " rguenth at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: xinliangli at gmail dot com @ 2010-11-02  0:37 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-11-21  7:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-02  0:37 [Bug rtl-optimization/46265] New: Missing ifcvt xinliangli at gmail dot com
2010-11-02 10:24 ` [Bug rtl-optimization/46265] " rguenth at gcc dot gnu.org
2010-11-03  5:25 ` davidxl at gcc dot gnu.org
2010-11-03  5:59 ` davidxl at gcc dot gnu.org
2010-11-04  0:55 ` xinliangli at gmail dot com
2021-11-21  7:21 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).