public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/35560]  New: Missing CSE/PRE for memory operations involved in virtual call.
@ 2008-03-12 20:44 xinliangli at gmail dot com
  2008-05-05  5:58 ` [Bug middle-end/35560] " pinskia at gcc dot gnu dot org
                   ` (13 more replies)
  0 siblings, 14 replies; 19+ messages in thread
From: xinliangli at gmail dot com @ 2008-03-12 20:44 UTC (permalink / raw)
  To: gcc-bugs

In the following example, three loads to the vtable pointer value can be CSEed,
so are two accesses to the same vtable entry (for foo), but final assembly
dumping indicate otherwise.  It is true that the object pointed to by ap may be
modified by the calls, but this does not apply to the vptr field.

class A {

public:

virtual int foo(int i);
virtual int bar(int i);

private:
int a;
};

int test(A* ap, int i)
{

   int r1 = ap->foo(i);
   int r2 = ap->bar(i);

   return r1+r2 + ap->foo(i);
}
     ...
.LCFI4:
        movq    (%rdi), %rax
        movl    %esi, %r12d
        call    *(%rax)
        movl    %eax, %r13d
        movq    (%rbx), %rax   <----- redundant
        movl    %r12d, %esi
        movq    %rbx, %rdi
        call    *8(%rax)
        movl    %eax, %ebp
        movq    (%rbx), %rax   <---- redundant
        movl    %r12d, %esi
        movq    %rbx, %rdi
        call    *(%rax)             <-- *(%rax) is redundant
        leal    (%rbp,%r13), %edx
        movq    8(%rsp), %rbx
        movq    16(%rsp), %rbp
        movq    24(%rsp), %r12
        movq    32(%rsp), %r13
        addq    $40, %rsp
        leal    (%rdx,%rax), %eax
        ret


-- 
           Summary: Missing CSE/PRE for memory operations involved in
                    virtual call.
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: xinliangli at gmail dot com


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


^ permalink raw reply	[flat|nested] 19+ messages in thread
[parent not found: <bug-35560-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2023-01-09 14:30 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-12 20:44 [Bug middle-end/35560] New: Missing CSE/PRE for memory operations involved in virtual call xinliangli at gmail dot com
2008-05-05  5:58 ` [Bug middle-end/35560] " pinskia at gcc dot gnu dot org
2008-11-29 22:44 ` steven at gcc dot gnu dot org
2008-11-30 11:58 ` rguenth at gcc dot gnu dot org
2008-11-30 12:10 ` rguenth at gcc dot gnu dot org
2008-11-30 19:29   ` Andrew Thomas Pinski
2008-11-30 19:30 ` pinskia at gmail dot com
2008-11-30 19:40 ` rguenth at gcc dot gnu dot org
2010-02-03 18:30 ` davidxl at gcc dot gnu dot org
2010-02-03 21:24 ` rguenth at gcc dot gnu dot org
2010-02-03 21:44 ` davidxl at gcc dot gnu dot org
2010-02-03 21:49 ` steven at gcc dot gnu dot org
2010-02-03 21:54 ` rguenth at gcc dot gnu dot org
2010-02-03 21:55 ` davidxl at gcc dot gnu dot org
2010-02-03 21:56 ` rguenth at gcc dot gnu dot org
2010-02-03 22:06 ` davidxl at gcc dot gnu dot org
     [not found] <bug-35560-4@http.gcc.gnu.org/bugzilla/>
2022-12-30 21:46 ` witold.baryluk+gcc at gmail dot com
2023-01-09 10:14 ` rguenth at gcc dot gnu.org
2023-01-09 14:30 ` m.cencora at gmail dot com

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).