https://bugs.llvm.org/show_bug.cgi?id=38241

            Bug ID: 38241
           Summary: Opportunity to skip dereferencie and move
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedb...@nondot.org
          Reporter: david.bolvan...@gmail.com
                CC: llvm-bugs@lists.llvm.org

Code:
typedef struct X {
    int *p;
    int *q;
} example_t;

int foo(example_t *e, int x) {
    *e->p = x;
    example_t c = *e;
    return *c.p;
}

Clang trunk -O3
foo(X*, int):                             # @foo(X*, int)
        mov     rax, qword ptr [rdi]
        mov     dword ptr [rax], esi
        mov     rax, qword ptr [rdi]
        mov     eax, dword ptr [rax]
        ret

GGC trunk
foo(X*, int):
        mov     rdx, QWORD PTR [rdi]
        mov     eax, esi
        mov     DWORD PTR [rdx], esi
        ret

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to